[PHP] Need help to understand a code

2012-09-22 Thread Ashickur Rahman Noor
Hi all

I need some help to understand a code. The code is like this

$result = mysql_query($sSQL) or die(err:  . mysql_error().$sSQL);
 if($row = mysql_fetch_array($result))
 {
   foreach($row as $key =$value){ $$key=$value;}
 }


I don't get the code from the foreach loop.
--
Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
2048R/89C932E1 http://goo.gl/TkP5U
Coordinator - Public Relation Cell, FOSS Bangladesh
http://fossbd.org/  Mozilla
Reps http://reps.mozilla.org
01199151550, 01551151550


Re: [PHP] Need help to understand a code

2012-09-22 Thread Stefan Wixfort

On 22.09.2012 12:34, Ashickur Rahman Noor wrote:

Hi all

I need some help to understand a code. The code is like this

$result = mysql_query($sSQL) or die(err:  . mysql_error().$sSQL);

 if($row = mysql_fetch_array($result))
 {
   foreach($row as $key =$value){ $$key=$value;}
 }



I don't get the code from the foreach loop.


I assume that you mean the meaning of $$key = $value.
This is a variable variable[1]
This means if you have a key in your array named dino then you assign 
$dino the value of $value for the current row.


so: $key = 'dino', $value = 'saur'
= $$key = $value = $$key = 'saur' = $dino = 'saur'

Hope this was somewhat helpful and understandable.

[1] http://php.net/manual/en/language.variables.variable.php


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