How can a location string be generated in PHP to display a breadcrumb navigation structure on a printer-friendly page?

To generate a location string in PHP for displaying a breadcrumb navigation structure on a printer-friendly page, you can use an array to store the hierarchy of the current page's location. Then, you can iterate through the array to construct the breadcrumb string. This string can be displayed on the printer-friendly page to provide users with a clear navigation path.

<?php
// Define the hierarchy of the current page's location
$location = array(
    'Home' => 'index.php',
    'Products' => 'products.php',
    'Printer-Friendly Page' => ''
);

// Generate the breadcrumb string
$breadcrumb = '';
foreach ($location as $label => $url) {
    if (!empty($url)) {
        $breadcrumb .= '<a href="' . $url . '">' . $label . '</a> > ';
    } else {
        $breadcrumb .= $label;
    }
}

// Display the breadcrumb on the printer-friendly page
echo $breadcrumb;
?>