From:             webmaster at baz-x dot at
Operating system: WinXP Home Edition Build 2600
PHP version:      4.3.11
PHP Bug Type:     Feature/Change Request
Bug description:  Maybe a nice function for future releases

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 bug report at http://bugs.php.net/?id=33926&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33926&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33926&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33926&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33926&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33926&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33926&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33926&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33926&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33926&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33926&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33926&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33926&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33926&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33926&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33926&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33926&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33926&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33926&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33926&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33926&r=mysqlcfg

Reply via email to