From:             [EMAIL PROTECTED]
Operating system: Debian sid
PHP version:      4.1.1
PHP Bug Type:     Arrays related
Bug description:  array_slice destroys numeric keys

The array_slice function destroys keys that are numeric (even if used as
strings), but not string keys.  This is a serious bug, which makes the
function unusable.  I had to write my own function to correctly take the
slice of an array.  If this is indeed intended behavior, then it should be
noted as such in the manual, and a new function added to take array slices
that does not destroy numeric keys.

<?
    $a = array("7" => "foo", "f" => "bar", "13" => "blah");
    print_r($a);
    print_r(array_slice($a, 0));
?>

Array
(
    [7] => foo
    [f] => bar
    [13] => blah
)
Array
(
    [0] => foo
    [f] => bar
    [1] => blah
)

-- 
Edit bug report at http://bugs.php.net/?id=15520&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=15520&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=15520&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=15520&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=15520&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15520&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=15520&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=15520&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=15520&r=submittedtwice

Reply via email to