HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Programming/Scripts (http://www.howtoforge.com/forums/forumdisplay.php?f=7)
-   -   Strange behaviour of foreach in PHP 4.3.11 (http://www.howtoforge.com/forums/showthread.php?t=102)

minimi 26th May 2005 17:13

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?

flo 26th May 2005 19:51

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

Flo

minimi 27th May 2005 13:46

Is this bug fixed in PHP 5? Or do I have to use PHP 4.3.9?

falko 30th May 2005 20:20

As far as I know PHP 5 seems to behave the "normal" way...


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

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