Enhancement / Idea for a function in the PHP parser - array_recursive_keys($array, $keys)

From: Date: Tue, 06 Nov 2012 15:06:27 +0000
Subject: Enhancement / Idea for a function in the PHP parser - array_recursive_keys($array, $keys)
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-14922@lists.php.net to get a copy of this message
Dear Sir/Madam, We are a proud user of PHP but we need a function which doesn't seem to exist. It is a very simple function which is now created by calling a foreach loop, but if it is possible to do this action in the parser, it would be truly awesome. //Example of my idea: $keys = array( 'Rss', 'Channel', 'Item', ); $array = array( 'Rss' => array( 'Channel' => array( 'Stuff' => 'Some random stuff I do not need', 'Item' => array( array('An', 'Item'), array('One', 'More', 'Item'), array('Cn', 'Item'), array('The', 'Fourth', 'Item in the items Array'), ) ) ) ); print_r(array_recursive_keys($array, $structure)); //returns $array['Rss']['Channel']['Item'] /* * 0 => array( * 0 => 'An', * 1 => 'Item' * ), * 1 => array( * 0 => 'One', * 1 => 'More', * 2 => 'Item' * ), * 2 => array( * 0 => 'Cn', * 1 => 'Item' * ), * 3 => array( * 0 => 'The', * 1 => 'Fourth', * 2 => 'Item in the items Array' *), */ //You could define array_recursive_keys($array, $keys) as the following: function array_recursive_keys($array, $keys){ foreach($keys as $key){ $array = $array[$key]; } return $array; } I am not entirely sure, but I think if the PHP parser can handle this directly it would improve the speed a lot. I will highly appreciate it if you take my enhancement in considoration. With kind regards, ________________________________ Jelmer Dröge Developer [cid:image001.jpg@01CDBC35.098C2340] T: +31 (0)10 - 30 200 30 Weena 73 3013 CH Rotterdam W: www.expandonline.nl<http://www.expandonline.nl/?utm_source=footer&utm_medium=email&utm_campaign=nieuws> [cid:image002.jpg@01CDBC35.098C2340] Jelmer Dröge<http://www.linkedin.com/profile/view?id=93198810> E: jdroge@expandonline.nl [cid:image003.jpg@01CDBC35.098C2340] @ExpandOnline<http://www.twitter.com/expandonline> ________________________________ Laatste nieuws<http://www.expandonline.nl/over-ons/nieuws.html> [cid:image004.jpg@01CDBC35.098C2340] Wat kost een plaatsing? De hamvraag van elke (e-)recruiter!<http://www.expandonline.nl/nieuws/wat-kost-een-plaatsing-de-hamvraag-van-elke-e-recruiter>

« previous php.webmaster (#14922) next »