Re: PHP 4.0 Bug #6414 Updated: foreach() doesn't accept string for an argument

From: Date: Tue, 29 Aug 2000 16:39:38 +0000
Subject: Re: PHP 4.0 Bug #6414 Updated: foreach() doesn't accept string for an argument
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-31090@lists.php.net to get a copy of this message
No, it doesn't: $b = "abcdef" ; $b = (array)$b ; $x = 0 ; foreach( $b as $c ) { echo "$x: $c<br>" ; $x++ ; } ; echo "size: " . sizeof( $b ) ; this outputs: 0: abcdef size: 1 php4-200008290745 (latest CVS). At 03:12 PM 8/29/00 +0000, Bug Database wrote the following: -------------------------------------------------------------- >ID: 6414 >Updated by: jmoore >Reported By: cynic@mail.cz >Status: Closed >Bug Type: Scripting Engine problem >Assigned To: >Comments: > >You need to cast your string as an array.. > ><?php > >$b = "abcdefgh" ; >$b = (array)$b; > >foreach( $b as $y ) { > echo $y ; >}; > >?> > >Works. > >James > >Full Bug description available at: http://bugs.php.net/?id=6414 ------end of quote------ ____________________________________________________________ Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. cynic@mail.cz ICQ: 2808 2505

« previous php.dev (#31090) next »