Lab 12, Part 2 -------------- This was the one about Taekwondo weight categories. It was marked out of 4. Here's a simple, concise solution: 'Welterweight', 57 => 'Featherweight', 49 => 'Flyweight') : array(80 => 'Welterweight', 68 => 'Featherweight', 58 => 'Flyweight'); $user_class = 'Heavyweight'; foreach ( $weight_classes as $limit => $class ) { if ( $user_weight <= $limit ) { $user_class = $class; } } echo "

Your class: {$user_class}.

"; ?> An if-else could be used in place of the conditional operator. A break statement could be put into the one-armed conditional to improve efficiency. There are billions of other ways of writing a correct version of this program, e.g. in your arrays, you might have the keys and values the 'other way around', or you might you might put the whole array into reverse order (and then <= becomes >). Here are some of the reasons why you may not have scored 4: - if your code had a lot of duplication (e.g. two foreach-loops) - if your code got the wrong answers for people whose weight equals the limit, e.g. a 57 kg woman is a featherweight, not a welterweight - if you found it necessary to stick an artificial weight limit on the heavyweights Solutions that coded the weight limits into if-statements, instead of putting them into arrays (as per the instructions on the lab sheet), typically scored zero, along with solutions that did not compile or did not work at all. Lab 12, Part 4 -------------- This was the pizza program. It was marked out of 6. It was a gift. The key - which most of you realised - is to use one or more associative arrays to map pizza sizes and toppings to their prices - rather than coding the prices into if-statements. Here's a simple solution: 8, 'medium' => 12, 'large' => 16); $crust_prices = array('thin' => 0, 'deep' => 2); $toppings_prices = array('mushrooms' => 0.5, 'olives' => 0.5, 'nail' => 1, 'beef' => 1.5); $home_delivery_charge = 3; // Get user's input $size = $_GET['size']; $crust = $_GET['crust']; if ( isset( $_GET['toppings'] ) ) { $toppings = $_GET['toppings']; } else { $toppings = array(); } $is_for_home = isset( $_GET['delivery'] ); // Calculations $cost = 0.0; $cost += $size_prices[$size]; $cost += $crust_prices[$crust]; foreach ( $toppings as $topping ) { $cost += $toppings_prices[$topping]; } if ( $is_for_home ) { $cost += $home_delivery_charge; } // Output echo "

Pay us: {$cost}.

"; ?> If you lost a mark or two, the probable reasons include: - you did not type in the prices correctly, e.g. check the price of finger nails and the price of spicy beef - you did not use the correct keys, e.g. the key for finger nails is 'nail' - look at the form! Similarly, the key for home delivery is 'delivery', not 'home' - 'home' is the value, not the key - you did not use isset properly to check whether the user had checked any toppings or whether the user had checked for home delivery or not - you left in some redundant statements - some of you made heavy work of looking prices up in your array(s): you used extra ifs or even foreach's inside foreach's. Part 2 of lab sheet 11 (finding the price of apples, etc.) showed you that none of this was needed