ID:               33926
 Updated by:       [EMAIL PROTECTED]
 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

Reply via email to