ID:               24159
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rsen010 at ec dot auckland dot ac dot nz
-Status:           Open
+Status:           Verified
-Bug Type:         Documentation problem
+Bug Type:         Arrays related
-Operating System: windos 2000
+Operating System: Any
 PHP Version:      4.3.2
 New Comment:

This behaviour was introduced in 4.3.0 - reclassifying as an array
problem.
I don't know if the behaviour or the documentation should be changed.


Previous Comments:
------------------------------------------------------------------------

[2003-06-12 15:38:20] rsen010 at ec dot auckland dot ac dot nz

Description:
------------
Hi,
When I was going through “Chapter 7.types” in PHP manual I found
something confusing regarding the following statement “Having e.g. the
highest index being -6 will result in -5 being the new key” (under
Syntax – specifying with array()).What actually happens is it Php
starts indexing from zero if lowest index is negative value unless
there is no index of zero. 
But amazing thing is sometimes it omit some values unless.
Just consider the following examples.
Ex:1
$a  = array(-3=>'February', 'March');
print_r($a);
This will prints out the folloiwng
> Array ( [-3] => February [0] => March )

Ex:2
$a  = array( 'January', '0'=>'a','b', 'c',-3=>'February', 'March');
print_r($a);
 This will prints out the folloiwng                
Array ( [0] => a [1] => b [2] => c [-3] => February [3] => March )     
  
 
 Please be kind to check this out if I’m correct and reply me.
 Thanks
 Naleen


Reproduce code:
---------------
$a  = array(-3=>'February', 'March');
print_r($a);
$a  = array( 'January', '0'=>'a','b', 'c',-3=>'February', 'March');
print_r($a);

Expected result:
----------------
Array (-3=>February, [-2] => March );
Array ( [1]=>January [0] => a [2] => b [3] => c [-3] => February [4] =>
March )

Actual result:
--------------
Array ([-3] => February [0] => March )
Array ( [0] => a [1] => b [2] => c [-3] => February [3] => March )


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=24159&edit=1

Reply via email to