note 59152 added to function.extract

From: Date: Sun, 27 Nov 2005 19:41:22 +0000
Subject: note 59152 added to function.extract
Groups: php.notes 
Request: Send a blank email to php-notes+get-99204@lists.php.net to get a copy of this message
Sometimes you may want to extract only a named subset of the key/value pairs in an array. This keeps things more orderly and could prevent an unrelated variable from getting clobbered from an errant key. For example, $things = 'unsaid'; $REQUEST = array(He=>This, said=>1, my=>is, info=>2, had=>a, very=>3, important=>test, things=>4); $aVarToExtract = array(my, important, info); extract (array_intersect_key ($REQUEST, array_flip($aVarToExtract))); will extract $my = 'is'; $important = 'test'; $info = 2; but will leave certain $things = 'unsaid' Csaba Gabor from Vienna NB. Of course the composite request coming in from a web page is in $_REQUEST. ---- Manual Page -- http://www.php.net/manual/en/function.extract.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59152 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59152&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59152&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59152&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59152&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59152&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59152&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59152&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59152&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99204) next »