Extract and compact
int extract (array var_arr)
stores all the values in the array into symbol table with the key of the array
as variable name and value as value of the corresponding variable.
<?php
$array = array(’ab’=>’hai’);
extract($array);
echo $ab;
//// will output hai
?>
int compact(mixed varname)
which is the reverse process of compact .
It takes the string containing variable name as parameter and convert it
into an array with variable name as key and value as its value
<?php
$fname = “Jhon”;
$lname = “Rubin”;
$age = “25″;
$ar_str = array (”fname”, “lname”);
$result = compact ($ar_str);
print_r($result);
?>
will output
Array
(
[fname] = Jhon
[lname] = Rubin
[age] = 25
)
