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 trialOleksii Temchenko
3,474 PointsWhy do we need $id as the first argument in echo get_item_html($id, $catalog[$id])?
It seems that we are not really utilising $id later on in function get_item_html($id, $item)
it is not simply using it, needs only $catalog[$id] to get desired output.
I have tried removing $id as arguments from both functions and everything worked fine. Can someone explain, why we need it? <?php
function get_item_html( $item){/we really need only $item = $catalog[$id] to get output, I do not see how function utilise $id itself/
$output = "<li><a href = '#'><img src = '"
.$item["img"] . "' alt = '"//search for desired property and adds their locations
.$item["title"] ."'/>" .
"<p>View detaiils</p>" .
"</a></li>";
return $output;
}
$categories= array_category($catalog,$section); foreach($categories as $id ){/generating random catalog id, outputs [0]=>int(102) [1]=>int(103)+2items/
echo get_item_html( $catalog[$id]);
}?>
barbarak
36,789 PointsBecause it will be needed in a later video I suspect.....
Julien Rotundo
10,018 PointsJulien Rotundo
10,018 PointsI have the same question. I did the same test.