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, 17: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
  #2  
Old 26th May 2005, 19: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, 13: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, 20:20
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
Default

As far as I know PHP 5 seems to behave the "normal" way...
__________________
Falko
--
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 04:53.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Sponsored Links: Unified Communications: Thoughts, Strategies and Predictions
Join the discussion.
www.seamlessenterprise.com

IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com

Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com

Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com

Red Hat Virtual Experience - a free virtual event. Dec. 9th