RE: [PHP] Warning: Invalid argument supplied for foreach()

From: Date: Sun, 06 Jul 2003 21:14:07 +0000
Subject: RE: [PHP] Warning: Invalid argument supplied for foreach()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-154147@lists.php.net to get a copy of this message
>Hi all, >I am getting crazy, can't understand what i missed! >Does anybody know? > >$champs = array ("titre_art" => "h3" ,"nom" => >"bleu", "prenom" => "green", >"resume" => "bold"); > >foreach($champs as $key => $value) { > > > echo "<td class='$value'>$row($key))</td>"; > } never used foreach()... but I would check the following: $row($key)) <= appears to have an extra ) though it would just be printed in your example $row($key) <= if it is an array reference, should be $row[$key] Here is another way to do your problem though while(list($key,$value)=each($champs)){ echo "<td class='$value'>$key</td>"; } Dave

« previous php.general (#154147) next »