PX : code

Associative array to global variables by Ondra Zizka
Download this code


<?
function arr2vars($arr, $pref="", $suff=""){
  while (list($xkey, $val) = each($arr)){
    //global ${$pref.$xkey.$suff};
    eval("global \$$pref$xkey$suff;");
    ${$pref.$xkey.$suff} = $val;
  }
}

/* use:
$arr = Array("ahoj"=>"lidi", "jakse"=>"mate");
arr2vars($arr);
echo $ahoj;
*/
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.