Page 1 of 1

need help debugging error in breadcrumbs code

Posted: Fri Apr 22, 2005 9:20 am
by bruceg
Hello all,

when I try to run the follow breadcrumbs code, I receive the following error.

Parse error: syntax error, unexpected '=', expecting ')' in C:\Inetpub\wwwroot\includes\crumbs.php on line 8

here is the code I am using for the breadcrumbs

Code: Select all

<?php
echo '<ul id="crumbs">
';
/* get array containing each directory name in the path */
$parts = explode("/", dirname($REQUEST_URI));  
echo '<li><a href="/">Home</a></li>
';
foreach ($parts as $key =(> $dir) {
        switch ($dir) {
        <strong>case "about": $label = "About Us"; break;</strong>
        /* if not in the exception list above, 
            use the directory name, capitalized */
        default: $label = ucwords($dir); break;   
        }
        /* start fresh, then add each directory back to the URL */
        $url = "";
        for ($i = 1; $i <= $key; $i++) 
           { $url .= $parts[$i] . "/"; }
        if ($dir != "") 
           echo "<li>> <a href="/$url">$label</a></li>
";
}
echo "</ul>
";
?>
any assistance in debugging is greatly appreciated.

regards,

Bruce

Posted: Fri Apr 22, 2005 10:04 am
by shiznatix
you forgot a ) on line 8. make line 8

Code: Select all

foreach ($parts as $key =(> $dir)) {

Posted: Fri Apr 22, 2005 10:15 am
by bruceg
thanks for the repley, but I still get the same error,

I now have for line 8

Code: Select all

foreach ($parts as $key =(> $dir)) {

Posted: Fri Apr 22, 2005 12:21 pm
by nickvd
bruceg wrote:thanks for the repley, but I still get the same error,

I now have for line 8

Code: Select all

foreach ($parts as $key =(> $dir)) {
That is not legitimate code.... try:

Code: Select all

foreach ($parts as $key => $dir) {