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 trial

PHP Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Breadcrumbs

Siraj Khan
Siraj Khan
3,451 Points

In the breadcrumbs class why do we repeat echo $item["category'] twice.?

php

In the breadcrumbs class:

      <a href="catalog.php">Full Catalog</a>
      &gt; <a href="catalog.php?cat=
      <?php echo strtolower($item["category"]); ?>">
      <?php echo $item["category"]; ?></a>
      &gt; <?php echo $item["title"]; ?>

why do we repeat echo $item["category'] twice.?? Please help.

1 Answer

theodevries
theodevries
15,895 Points

Hi 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