View Full Version : PHP configuration problem?? foreach not behaving

01-05-2006, 12:27 PM
I have got PHP 4.3.10 Installed on my local system (windows) and server (Fedora).

foreach loop runs perfectly on my local system but it gives me problems on the server.

here is a sample code.

$FilenameParameters1 = array('ar', 'bg', 'bc', 'far');
foreach ($FilenameParameters1 as $key) {
echo $key;

on local system it prints the values
"ar bg bc far"

but on the server it prints
"Array Array Array Array"

it works fine if i change $key to $k=>$key in the loop. Because of that i'm not able to run any libraries or classes downloaded from the internet.

please HELP me sort this out.


01-05-2006, 04:16 PM
Seems odd.

Is there a difference between


On localhost and the server?

01-05-2006, 06:10 PM
there are no configuration issues that affect the operation of foreach() , I can only assume that the code you posted in only part of the code ?, have you tried your example (just that and nothing else) on the linux box ?

01-06-2006, 11:06 AM

actually this is not the first time i have faced this problem. It always happens when i upload any code from my windows server to fedora server. I always end up changing all occurances of foreach to suit the fedora server.

and yes bcarl the print_r works same on both. It prints the contents of an array on both servers...


Velox Letum
01-06-2006, 11:41 AM
Perhaps the copy of PHP on your server was compiled improperly. Try the latest binary or recompile from the source.