I have one dimensional array as below
$arr=array("a"=>'1',"b"=>2,'c'=>'3');
i need to use keys of array i.e a,b,c as variable .. so that
echo $a should display 1 , $b should display 2 and so on
possible in php?
extract($arr)
Is the correct answer to this question.
http://www.php.net/manual/en/function.extract.php
Its generally not considered a good idea though. Whats wrong with $arr['a']?
There is a built-in function for this called extract()
I just do it like this for basic arrays
$arr=array("a"=>'1',"b"=>2,'c'=>'3');
foreach($arr as $k=$v){ $$k=$v; }
echo $a; //prints 1
echo $c; //prints 3
EDIT: Check FDL's answer