Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 26th May 2005, 16:13
minimi minimi is offline
Junior Member
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Strange behaviour of foreach in PHP 4.3.11

I found a strange behaviour of foreach in PHP 4.3.11. For example, if you have the following code:

PHP Code:
<?
$elements
[0] = 'bla';
$elements[1] = 'blubb';

foreach(
$elements as $element){
  
print_r($element);
}
?>
it prints

Code:
Array
        (
            [0] => bla
            [1] => 0
        )
Array
        (
            [0] => blubb
            [1] => 1
        )
instead of the strings bla and blubb... Is this a bug in PHP 4.3.11?
Reply With Quote
Sponsored Links
  #2  
Old 26th May 2005, 18:51
flo flo is offline
Junior Member
 
Join Date: May 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Seems to be a bug in PHP 4.3.10 and 4.3.11: http://bugs.php.net/bug.php?id=30914

Flo
Reply With Quote
  #3  
Old 27th May 2005, 12:46
minimi minimi is offline
Junior Member
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is this bug fixed in PHP 5? Or do I have to use PHP 4.3.9?
Reply With Quote
  #4  
Old 30th May 2005, 19:20
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,735 Times in 2,571 Posts
 
Default

As far as I know PHP 5 seems to behave the "normal" way...
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:05.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.