Maybe its due to me looking at the code so long I just can't see whats going on but can anyone tell me why the below code is timing out?
$level = 1;
while($level >= 0) {
$breadcrumbNav = $linkArray[$level][1].$breadcrumbNav;
// $linkArray[$level][5] will always be less then the current value for $level but not always a concurrent decrement
$level = $linkArray[$level][5];
}
global variable is $linkarray is used before its defined
Sorry, I should have said, everything is defined before hand, there is so much code I didn't post it all as I think its an issue with my logic in the while loop as if I change the below line:
$level = $linkArray[$level][5];
To:
echo $linkArray[$level][5];
$level--;
It outputs ok.
i debugged the code coz m lazy today... while ihave not full code cant make any sense out of it...the output is debugged oke anyway... got just 2 errors before the globals are defined before they are used :P
$breadcrumbNav
and
$linkArray
Maybe this might make more sense, I cleaned it up to remove non relevant code.
$linkParent = array();
$currentPage = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$linkArray = self::getNavArray(); // returns an array of all available links on the site in the format (id, link_text, link, sequence, pages_to_display_on, parent)
for($i=0;$i<sizeof($linkArray);$i++) {
if(strstr($currentPage,$linkArray[$i][2]))
$linkParent = $linkArray[$i][5];
}
$level = $linkParent;
while($level >= 0) {
$breadcrumbNav = $linkArray[$level][1].$breadcrumbNav;
$level = $linkArray[$level][5];
}
now only $breadcrumbNav aint defined... but parsed good ;)
line 16 gives the error not used before defined anyway
$breadcrumbNav = $linkArray[$level][1].$breadcrumbNav;
Sorry I'm having a forgetful day, it was one of the lines I removed, here is the proper code.
$breadcrumbNav = '';
$linkParent = array();
$currentPage = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$linkArray = self::getNavArray(); // returns an array of all available links on the site in the format (id, link_text, link, sequence, pages_to_display_on, parent)
for($i=0;$i<sizeof($linkArray);$i++) {
if(strstr($currentPage,$linkArray[$i][2]))
$linkParent = $linkArray[$i][5];
}
$level = $linkParent;
while($level >= 0) {
$breadcrumbNav = $linkArray[$level][1].$breadcrumbNav;
$level = $linkArray[$level][5];
}
It seems that its timing out on the last line of the while loop: $level = $linkArray[$level][5];
parsed ok without errors so it good ;)
no time out but check your configuratios apache/php/mysql can be horrible sometimes :P
what are you using for development ?
Got it working, it was my logic with the while loop and the array. Thanks for your help. :)
be welcome :P