From:             rsen010 at ec dot auckland dot ac dot nz
Operating system: windos 2000
PHP version:      4.3.2
PHP Bug Type:     Documentation problem
Bug description:  Php starts indexing from zero if lowest index is negative 

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 bug report at http://bugs.php.net/?id=24159&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24159&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24159&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24159&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24159&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24159&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24159&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24159&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24159&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24159&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24159&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24159&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24159&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24159&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24159&r=gnused


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to