PHP foreach problem

Discuss Programming

PHP foreach problem

Postby X11 » Mon Oct 18, 2004 6:37 am

I have come across a strange problem in my scripts with a foreach loop.

Here is the array...
Code: Select all
$LinksLocal = array(
                                                                               
        array( 'name' => "Main Page", 'loc' => "main" ),
        array( 'name' => "About", 'loc' => "about" ),
                                                                               
);


Code: Select all
function PrintLinks($Sepr)
{
        global $LinksLocal;
                                                                                                                                                             
        foreach( $LinksLocal as $LinkI )
        {
                LocalLink($LinkI[name],$LinkI[loc]);
                print "<br>";
                BugOut("PrintLinks: LinkI[name]=".$LinkI[name]." LinkI[loc]=".$LinkI[loc]);
        }
}


Despite this code, it just does the first object in the $LinksLocal array, uses the LocalLink function to print it, and then exits, forgetting about the object after it.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby X11 » Thu Oct 21, 2004 11:09 am

Note: This question is now redundant and I have fixed it.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests