Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Bug in Foreach.....???
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



Report this thread to moderator Post Follow-up to this message
Old Post
Rob
12-23-04 08:58 PM


Re: Bug in Foreach.....???
> 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



Report this thread to moderator Post Follow-up to this message
Old Post
Hilarion
12-23-04 08:58 PM


Re: Bug in Foreach.....???
"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



Report this thread to moderator Post Follow-up to this message
Old Post
Rob
12-23-04 08:58 PM


Re: Bug in Foreach.....???
> 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



Report this thread to moderator Post Follow-up to this message
Old Post
Hilarion
12-28-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:09 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.