You may want to do something like this instead: <?
function my_extract($arr)
{
if(is_array($arr) && sizeof($arr))
{
while(list($key,$val) = each($arr)
{
$new_var = str_replace(' ','_',$key);
global $$new_var;
$$new_var = $val;
}
}
}
?>
--Joe
On Sun, Nov 18, 2001 at 04:21:46PM -0500, David Bernier wrote:
> There is this array which I would like to convert into a series variables using the
>extract function:
>
> <?
> $oz = array(
> "lion" => "courage",
> "dorothy" => "kansas",
> "scarecrow" => "brain"
> "tin man" => "heart");
>
> extract($oz);
> ?>
>
> now, I would like to access my new variables. it is obviously easy for $lion,
>$dorothy, and $scarecrow but it isn't for "tin man".
>
> from this, I have 3 or 4 questions:
> 1) has $oz["tin man"] been passed into a variable?
> 2) if yes, how do I access the variable that came out of $oz["tin man"]?
> 3) let's pretend that I have no control over the names of the keys for $oz, how
>should I have called extract() to tell it to replace the space between "tin" and
>"man" by a underscore character?
> 4) finally, is there a way to access and retrieve that values of the symbol table
>without knowing their names?
>
> David
>
Joe Stump <[EMAIL PROTECTED]>
------------------------------------------------------------------------
"How would this sentence be different if pi equaled 3?"
msg40414/pgp00000.pgp
Description: PGP signature

