ID: 8032
Updated by: jason
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Closed
Bug Type: Arrays related
Operating System: FreeBSD 4.2-Release
PHP Version: 4.0.3pl1
New Comment:
This is actually not a bug. What you are running in to is php's auto-type conversion
when you are building your array.
$a["11"] automagicly will become a numeric index of $a[11]. Due to the way that
array_splice is designed, the array is completly changed, and thus the numeric indexes
are reset.
If you wish to prevent this from occuring, prefix the numeric string with 0.
ie
<?
$a["e"]="e";
$a["r"]="r";
$a["011"]="111";
$a["022"]="222";
array_splice ($a,0,1);
foreach ($a as $k=>$v) {
echo "$k=$v<br>";
}
?>
will produce
r=r
011=111
022=222
-Jason
Previous Comments:
------------------------------------------------------------------------
[2000-11-29 10:44:33] [EMAIL PROTECTED]
<?
$a["e"]="e";
$a["r"]="r";
$a["11"]="111";
$a["22"]="222";
array_splice ($a,0,1);
foreach ($a as $k=>$v) {
echo "$k=$v<br>";
}
?>
produce:
r=r
0=111
1=222
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=8032&edit=1
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]