For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > December 2004 > Bug in Foreach.....???









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Bug in Foreach.....???
Rob

2004-12-23, 4:03 pm

Hello all,


My provider upgraded from php version 4.3.x to 4.3.10. And I found out the
foreach construct is working different
When using as follows:

foreach($any_array as $item){
print_r($item)
}

$item is an array!!! The output is as follows:

array (
[0]=>'the value of the current array item'
[1]=>'the index of the current array item'
)

When using

foreach($any_array as $index->$item){
print_r($item);
}
it is working as expected printing the value of the array entry.

Is this a bug?
If not did I miss something?

See also the last note in
http://www.php.net/manual/nl/contro...res.foreach.php)


ROB


Hilarion

2004-12-23, 4:03 pm

> foreach($any_array as $item){
> print_r($item)
> }


Are you sure that it's "foreach" fault? Try "print_r( $any_array )"
before "foreach".
I do not have this effect in PHP 4.3.9.

Hilarion


Rob

2004-12-23, 4:03 pm


"Rob" <reply_@news_group.please> schreef in bericht
news:e_Byd.144636$lN.87412@amsnews05.chello.com...
> Hello all,
>
>
> My provider upgraded from php version 4.3.x to 4.3.10. And I found out the
> foreach construct is working different
> When using as follows:
>
> foreach($any_array as $item){
> print_r($item)
> }
>
> $item is an array!!! The output is as follows:
>
> array (
> [0]=>'the value of the current array item'
> [1]=>'the index of the current array item'
> )
>
> When using
>
> foreach($any_array as $index->$item){
> print_r($item);
> }
> it is working as expected printing the value of the array entry.
>
> Is this a bug?
> If not did I miss something?
>
> See also the last note in
> http://www.php.net/manual/nl/contro...res.foreach.php)
>
>
> ROB
>
>


It is solved.

The Zend Optimizer version 2.5.5 (version number according to my provider)
is causing the problem. When this is upgraded all works.

(See also the last note in
http://www.php.net/manual/nl/contro...res.foreach.php)

ROB


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com