#33926 [Opn->Bgs]: Maybe a nice function for future releases

From: Date: Sat, 11 Nov 2006 01:48:11 +0000
Subject: #33926 [Opn->Bgs]: Maybe a nice function for future releases
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104803@lists.php.net to get a copy of this message
ID: 33926 Updated by: tony2001@php.net Reported By: webmaster at baz-x dot at -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: WinXP Home Edition Build 2600 PHP Version: 4.3.11 New Comment: There is not much point to add functions to PHP which can be implemented in PHP itself in a couple of lines. Previous Comments: ------------------------------------------------------------------------ [2005-07-30 01:52:02] webmaster at baz-x dot at Description: ------------ Sorry if I did something wrong. This is my first time I submit a report. (Btw: when adding a note, the link "Click here to request a feature." redirects to bugs.php.net, is this correct?) I was looking for a function that deletes either integer keys or string keys (needed for my caching). As I didn't find a function I created a simple one. <?php function array_extract($array, $extract_type = 1) { foreach ( $array as $key => $value ) { if ( $extract_type == 1 && is_string($key) ) { // delete string keys unset($array[$key]); } elseif ( $extract_type == 2 && is_int($key) ) { // delete integer keys unset($array[$key]); } } return $array; } ?> You can of course define constants to have a nicer look, I have chosen these: EXTR_INT = 1; EXTR_STRING = 2 EXTR_INT will return an array where keys are only integer while EXTR_STRING will return an array where keys are only string I hope you find it useful. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33926&edit=1

« previous php.bugs (#104803) next »