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 trialSiraj Khan
3,451 PointsIn the breadcrumbs class why do we repeat echo $item["category'] twice.?
php
In the breadcrumbs class:
<a href="catalog.php">Full Catalog</a>
> <a href="catalog.php?cat=
<?php echo strtolower($item["category"]); ?>">
<?php echo $item["category"]; ?></a>
> <?php echo $item["title"]; ?>
why do we repeat echo $item["category'] twice.?? Please help.
1 Answer
theodevries
15,895 PointsHi Siraj,
The first item["category"] is used as a parameter in the link (after ?cat=) so the link points to the right category. The second is just the plain text the user sees as the link text.
if $item['category'] = 'flowers' the output in HTML would be:
<a href="catelog.php?cat=flowers">flowers</a>
So this would be the middle link in the breadcrumbs. I see in Alena's example the category is music.
Is the answer helpful?
Kind Regards