Search code examples
phpvariable-variables

Convert associative array to individual variables named by keys


I have array in following format. I want to convert it into another format like below.

Array
(
 [b2] => 2
 [b3] => 8
 [b4] => 2
 [b5] => 4
)

Is it possible key is converted into PHP variables and its value automatically assigned to variables? Is it possible?

$b2 = 2;
$b3 = 8;
$b4 = 2;
$b5 = 4;

Solution

  • looks like you want extract()