Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP configuration problem?? foreach not behaving

    Hey,
    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.

    PHP 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.

    Thanks

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Seems odd.

    Is there a difference between

    PHP Code:
    print_r($FilenameParameters1); 
    On localhost and the server?

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,084
    Thanks
    11
    Thanked 100 Times in 98 Posts
    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 ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey,

    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...


    Thanks

  • #5
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perhaps the copy of PHP on your server was compiled improperly. Try the latest binary or recompile from the source.
    "$question = ( to() ) ? be() : ~be();"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •