0

Normally this function returns a breadcrumb like this:

Home » Php » Test

But I want it to only display this:

» Test

So I added this line: return end(explode('Php',$str));.
But now it returns this error and I don't know what to do with it.

Strict Standards: Only variables should be passed by reference in /php/functions.php on line 112

line 112 is the last line before the function ends.
Could you guys please help me out I'm stuck at this error with my project.

Here is my code:

function breadcrumbs($separator = ' » ', $home = 'Home') {
// This gets the REQUEST_URI (/path/to/file.php), splits the string (using '/') into an array, and then filters out any empty values
$path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)));

// This will build our "base URL" ... Also accounts for HTTPS :)
$base = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';

// Initialize a temporary array with our breadcrumbs. (starting with our home page, which I'm assuming will be the base URL)
$breadcrumbs = Array("<a href=\"$base\">$home</a>");

// Find out the index for the last value in our path array
$pathkeys = array_keys($path); $last = end($pathkeys);

// Build the rest of the breadcrumbs
foreach ($path AS $x => $crumb) {
    // Our "title" is the text that will be displayed (strip out .php and turn '_' into a space)
    $title = ucwords(str_replace(Array('.php', '_'), Array('', ' '), $crumb));

    // If we are not on the last index, then display an <a> tag
    if ($x != $last)
        $breadcrumbs[] = "<a href=\"$base$crumb\">$title</a>";
    // Otherwise, just display the title (minus)
    else
        $breadcrumbs[] = $title;
}

// Build our temporary array (pieces of bread) into one big string
$str = implode($separator, $breadcrumbs);
//remove everything before "Php" in the string
return end(explode('Php',$str));
}

0 Answers0