'','last'=>'','phone'=>'','email'=>''); $array[] = array('first'=>'Jon','last'=>'Doe','phone'=>'555 555-5555','email'=>'john@doe.com'); $array[] = array('first'=>'Jane','last'=>'Doe','phone'=>'555 555-5555','email'=>'jane@doe.com'); $array[] = array('first'=>'Alice','last'=>'Anderson','phone'=>'123 456-7890','email'=>'user@domain.com'); $array[] = array('first'=>'Bob','last'=>'Bennet','phone'=>'111 222-3333','email'=>'clarkson@university.edu'); $array[] = array('first'=>'Carl','last'=>'Carlson','phone'=>'123 123-1234','email'=>'carl@carlson.name'); $array[] = array('first'=>'Devin','last'=>'Donaldson','phone'=>'333 222-1111','email'=>'ddonaldson@dd.name'); if ($_GET['type'] != 'list') { if (!is_numeric($_GET['id'])) { print 'Error: Id must be a number'; } else if($_GET['id'] < 0) { print 'Error: Id must be positive'; } else if($_GET['id'] > count($array)) { print 'Error: Id too large.'; } else { if ($_GET['type']=='string') { print $array[$_GET['id']]['first'] . ' ' . $array[$_GET['id']]['last'] . ' ' . $array[$_GET['id']]['phone'] . ' ' . $array[$_GET['id']]['email']; } if ($_GET['type']=='form') { print '
'; } if ($_GET['type']=='change') { // In a real system, we would store the changes here, but we haven't talked about that yet, so we'll keep things simple for now. print_r($_GET); } } } else { print ''; } ?>