#24116 [NEW]: Enhancement: extract() takes array of keys

From: Date: Tue, 10 Jun 2003 17:16:47 +0000
Subject: #24116 [NEW]: Enhancement: extract() takes array of keys
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-41627@lists.php.net to get a copy of this message
From: kop at meme dot com Operating system: All PHP version: 4.3.2 PHP Bug Type: Arrays related Bug description: Enhancement: extract() takes array of keys I want to get variables passed from the client into local (not global) variables. If the variable has not been passed from the client I do not want a local variable defined. While this can be coded for each variable I want to do this with, there is no way to abstract this operation into a function. The (untested) code to get a form variable 'foo' would be: if (array_key_exists($_POST, 'foo') { $foo = &{$_POST['foo'])} } // $foo may or may not be defined, so if I've got strict // error checking on I get a nice error if I ref an undefined //variable. And, $foo is nice and local so it won't show // where I don't send it. If extract() took an array of keys as another argument, extracting only those keys that are in the list, I could get the form variables, foo, bar, and baz with: extract($_POST, EXTR_REFS, '', array('foo', 'bar', 'baz')); -- Edit bug report at http://bugs.php.net/?id=24116&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=24116&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=24116&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24116&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24116&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24116&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24116&r=support Expected behavior: http://bugs.php.net/fix.php?id=24116&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24116&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24116&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24116&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24116&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24116&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24116&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24116&r=gnused

« previous php.bugs (#41627) next »