select specified elements from an array

From: Date: Tue, 22 May 2001 22:06:42 +0000
Subject: select specified elements from an array
Groups: php.general 
Request: Send a blank email to php-general+get-53945@lists.php.net to get a copy of this message
hello, I'd like to know if there is a more elegant and smoother way to retrieve some array elements with given keys and put them into an other array. Yes, I can write a function like the following, but maybe I missed some new PHP awesome feature or array function which does this job. So, is there anything which makes this function obsolete? function array_part($fromarray, $keys) { foreach($fromarray as $key => $val) { if (in_array($key, $keys) $anotherarray[$key] = $val; } return $anotherarray; } Papp Gyozo - pgerzson@freestart.hu

« previous php.general (#53945) next »