note 11764 rejected and deleted from array_slice by jmcastagnetto

From: Date: Tue, 06 Mar 2001 19:05:08 +0000
Subject: note 11764 rejected and deleted from array_slice by jmcastagnetto
Groups: php.notes 
Request: Send a blank email to php-notes+get-11950@lists.php.net to get a copy of this message
It's a pity you can't do something like this: $input = array ("a"=>"a string", "b"=>"b string", "c"=>"c string", "d"=>"d string", "e"=>"e string"); $get=array("a","e"); $out=array_slice($input,$get); //to give you $out=array("a"=>"a string","e"=>"e string") like you can with hash slices in perl.. of course you could use preg_grep or a work around like: function slice($arr,$keys) { foreach ($keys as $k) {$tmp[$k]=$arr[k];} return($tmp); } but that's bound to be slower..

« previous php.notes (#11950) next »