need help debugging error in breadcrumbs code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

need help debugging error in breadcrumbs code

Post 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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

you forgot a ) on line 8. make line 8

Code: Select all

foreach ($parts as $key =(> $dir)) {
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

Post 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)) {
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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) {
Post Reply