RE: Can someone explain this code snippet please?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux