#48944 [Opn]: unsetting an array does not reindex
| From: | info at speich dot net | Date: | Thu, 16 Jul 2009 13:14:14 +0000 |
| Subject: | #48944 [Opn]: unsetting an array does not reindex | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2495@lists.php.net to get a copy of this message | ||
ID: 48944
User updated by: info at speich dot net
Reported By: info at speich dot net
Status: Open
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
Sorry, better example:
<?php
$arr = array(5, 6, 7, 8);
print_r($arr);
unset($arr[2]);
print_r($arr);
?>
Output:
Array ( [0] => 5 [1] => 6 [2] => 7 [3] => 8 )
Array ( [0] => 5 [1] => 6 [3] => 8 )
Previous Comments:
------------------------------------------------------------------------
[2009-07-16 13:11:54] info at speich dot net
Description:
------------
I think it would be helpful if the documentation about unset would
mention:
Unsetting an array item removes it from the array, but does not change
the keys. Example:
<?php
$arr = array(5, 6, 7, 8);
print_r($arr);
unset($arr[3]);
print_r($arr);
?>
Output:
Array ( [0] => 5 [1] => 6 [2] => 7 [3] => 8 )
Array ( [0] => 5 [1] => 6 [2] => 7 )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48944&edit=1