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

2003-07-06 Thread Sævar Öfjörð
Don't you think it should be like this?

foreach($champs as $key=$value) {
echotd class='$value'$key/td;
//--^
}

-Original Message-
From: arnaud gonzales [mailto:[EMAIL PROTECTED] 
Sent: 6. júlí 2003 20:51
To: Php-General
Subject: [PHP] Warning: Invalid argument supplied for foreach() 

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;
 }

TIA.
zeg


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2003-07-06 Thread Dave [Hawk-Systems]
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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2003-07-06 Thread Philip Olson

On Sun, 6 Jul 2003, arnaud gonzales wrote:

 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;
 }

It works fine, you are using different code then the above.
In your actual code, make sure you pass in an array that
exists, as currently you are not.

One example reason, the foreach is inside a function and
$champs isn't available in the functions scope (global).

At any rate, before your foreach, var_dump($champs) and
it'll let you know what is up.

Regards,
Philip

p.s. In case $row is an array, you actually mean to write
it as $row[$key], but this is unrelated to the error that
foreach is providing.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php