Re: Feature?

From: Date: Wed, 26 Sep 2001 11:50:50 +0000
Subject: Re: Feature?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-68841@lists.php.net to get a copy of this message
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(); ?>

« previous php.general (#68841) next »