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?

-Steve

On Wednesday, September 26, 2001, at 06:50  AM, Alister wrote:

> Follow up to my own message:
>
> If you want to also skip even needing the empty 'array()' (new fianl
> example) - check if it is an array, and only do the first extract of
> the parameters if there's something there.
>
> <?php
> function foo($p='')
> {
>       $foodefault = array(
>               'foo_fred'=> '<strong>default fred</strong>',
>               'foo_banana' => '<strong>default bananananana</strong>',
>       );
>       if (is_array($p))
>               extract ($p, EXTR_PREFIX_ALL, 'foo');   // get values
>       extract ($foodefault, EXTR_SKIP, "foo");        // get defaults
>       echo  "$foo_fred / $foo_banana";
> }
>
> echo "Both in place: ";
> foo(array('fred' => 'hello', 'banana' => 'world'));
> echo "<br /> Now with a missing param: ";
> foo(array('fred' => 'hello'));
> echo "<br /> Now both missing params: ";
> foo(array());
> echo "<br /> and with no array: ";
> foo();
> ?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to