PHP Build a Basic PHP Website 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.?


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.

15,891 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