#6414 [Com]: foreach() doesn't accept string for an argument

From: Date: Mon, 17 Mar 2003 07:46:33 +0000
Subject: #6414 [Com]: foreach() doesn't accept string for an argument
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-35724@lists.php.net to get a copy of this message
ID: 6414 Comment by: yuki_yew78 at yahoo dot com Reported By: cynic at mail dot cz Status: Closed Bug Type: Scripting Engine problem Operating System: NT 4.0 SP5 PHP Version: 4.0 Latest CVS (29/08/2000) New Comment: me too Previous Comments: ------------------------------------------------------------------------ [2000-08-29 11:12:32] jmoore@php.net You need to cast your string as an array.. <?php $b = "abcdefgh" ; $b = (array)$b; foreach( $b as $y ) { echo $y ; }; ?> Works. James ------------------------------------------------------------------------ [2000-08-29 10:47:05] cynic at mail dot cz $b = "abcdefgh" ; foreach( $b as $y ) { echo $y ; } ; Warning: Invalid argument supplied for foreach() ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=6414&edit=1

« previous php.bugs (#35724) next »