Forum Moderators: phranque

Message Too Old, No Replies

PHP scripts issue

         

stefaandk

11:10 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



I seem to have an issue on my server running

php-4.3.10-2.4, scripts with the foreach loop don't work properly. They do work on other machines so it's no scripting issue as such. And php seems to be installed OK.
Contemplating the reinstall of PHP but before I do so maybe any tips as to what would be the cause of this PHP half working.

Thx

Chico_Loco

12:09 am on Jun 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try to locate where the cycle loops, and why. Is the script depeding on a local variable? If so, the configuration of your machine may not be providing those and thus you have some kind of loop.

stefaandk

1:13 am on Jun 21, 2005 (gmt 0)

10+ Year Member



It's a pretty basic script, not relying on anythign really.

<?
#foreach ($arr1 as $i) {action}
# as is the assignment

#integers no quotes req.
$arr1 =array(1,2,3,4,5);
#keys and values
$arr2 =array("file1" => "index.php","file2" => "default.php",);
#values only
$arr3 =array("index1.html","index2.html");

foreach ($arr1 as $i) {
echo $i, "<br>";
}
#echo both key and value
foreach ($arr2 as $key => $index) {
echo "$key - $index", "<br>";
}

foreach ($arr3 as $index) {
echo $index, "<br>";
}

?>

Instead of dispaying
1
2
3
4
5

it shows
array
array
array

But only on this one machine, works fine elsewhere.

coopster

11:08 am on Jun 22, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I know they (PHP developers) did some work on the foreach internals around that release and have seen some bug reports. Have you considered 4.3.11 [php.net]?