Re: Extract. Was Re: Feature?
| From: | Alister | Date: | Wed, 26 Sep 2001 15:17:45 +0000 |
| Subject: | Re: Extract. Was Re: Feature? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-68883@lists.php.net to get a copy of this message | ||
On Wed, 26 Sep 2001 09:47:57 -0500, you wrote:
>Just looking up that extract function, the manual says it extracts into
>the current symbol table. I assume that means that within foo() the
>array would be extracted into local variables. Is that right?
As http://www.php.net/manual/en/function.extract.php
says:
This function is used to import variables from an array into
the current symbol table.
^^^^^^^^^^^^^^^^^^^^^^^^
You might want to try declaring the variables that are to be extracted
as global - and see what happens, but I tend to prefer keeping things
to large configuration arrays and then local vars only where I can.
>> $foodefault = array(
>> 'foo_fred'=> '<strong>default fred</strong>',
>> 'foo_banana' => '<strong>default
>> bananananana</strong>',
>> );
Caveat Programmer: don't name the default array foo_default (or
'{PREFIX}_') - if you had a parameter called 'default', the first
extract would overwrite it, and the second would probably fail (or if
it was an array, extract it - but still not what you wanted).
Caveat Programmer 2: You have to name the default variables in the
array the full and proper post-prefixed name, extract does not appear
to be able to (currently) EXTR_PREFIX_ALL _and_ EXTR_SKIP.
Alister
Please don't send the mailing lists and CC me -
getting two copies just bugs me.