Some time I want to destroy a 1-key array, take away the key and just make it a variable. I designed a function to do this, and it works fine inside the function. declaring the array global, however, so that I can unset it globally, DOESN'T WORK.
I've had problems using global before, is there something I'm missing?
Here's my function, pretty simple:
function simplify_array($theArray)
{//changes the array to a value (highest value only way at present).
eval( 'global $' . $theArray . ';' );
eval( '$localArray = $' . $theArray . ';' );
if(is_array($localArray)){
foreach($localArray as $n=>$v){
$buffer = $v;
(is_numeric($buffer)?$quot='':$quot="'");
}
echo "before = " . $adminAction . "<br>";
eval( 'unset($' . $theArray . ');' );
echo "after = " . $adminAction . "<br>";
eval( '$' . $theArray . '= ' . $quot . ($quot?addslashes($buffer):$buffer) . $quot . ';' );
echo "final = " . $adminAction . "<br>";
}
}
$adminAction[1] = 'heather';
simplify_array('adminAction');
echo $adminAction; //darn thing still shows an array!!!!
thanks,
Sam