|
<?php function assign_from_array($array) {
$keys = array_keys($array);
for ($i=0; $i<count($array); $i++) {
$key = $keys[$i];
global ${$key};
${$key} = $array[$key];
}
} ?>
|
|
|
Usage Example
|
Example if external variables are not global in PHP. Variable "option" with value of "1" is passed to the script via the POST method.
echo $HTTP_POST_VARS['option'] // prints "1"
echo $option; // prints nothing
assign_from_array($HTTP_POST_VARS);
echo $option; // prints "1"
|
|
|
Rate This Script
|
|