RE: [PHP-DB] Can someone explain this code snippet please?
| From: | Peter Lovatt | Date: | Mon, 19 May 2003 20:12:02 +0000 |
| Subject: | RE: [PHP-DB] Can someone explain this code snippet please? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27897@lists.php.net to get a copy of this message | ||
Hey all, would someone be able to explain the following code to me? I've
never used a foreach loop and I've never seen the "$$" before a variable.
foreach loops through all members of an array
$$var is a variable who's name is a variable
eg
$abc='xyz'
$xzy = 'var1'
$$abc = $xyz = 'var1'
HTH
Peter
foreach ($cart as $isbn => $qty)
{
if($$isbn=="0")
unset($cart[$isbn]);
else
$cart[$isbn] = $$isbn;
}
Cheers,
Graeme :)
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php