Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCliff Jackson
2,887 PointsCan someone explain clearly what is happening here, why is the output A?
<?php
$flavors = array();
$flavors[1] = "Cake Batter";
$flavors[2] = "Cookie Dough";
if (isset($_GET["id"])) {
if (isset($flavors[$_GET["id"]])) {
echo $flavors[$_GET["id"]];
} else {
echo "B";
}
} else {
echo "A";
}
?>
1 Answer
Dennis Amiel Domingo
17,813 PointsThe "id" variable wasn't set therefore the conditional wasn't met.
At least I think that's what it is.
Cliff Jackson
2,887 PointsCliff Jackson
2,887 PointsThanks i figured it in the end.