Edit report at https://bugs.php.net/bug.php?id=65479&edit=1

 ID:                 65479
 Updated by:         ni...@php.net
 Reported by:        jordandoyle133 at gmail dot com
 Summary:            Accessing key -1 should return last value of array
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Arrays related
 Operating System:   All
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

This is not possible, because -1 is a valid array key. Consider:

    echo [-1 => -1, 0, 1, 2][-1]; // int(-1)


Previous Comments:
------------------------------------------------------------------------
[2013-08-19 18:33:28] jordandoyle133 at gmail dot com

Description:
------------
Accessing minus keys should start from the end of the array much like the 
behavior 
in Perl or Python 

Test script:
---------------
<?php
echo [1, 2, 3][-1] . PHP_EOL;
echo [3, 2, 1][-2] . PHP_EOL;
echo ['foo', 'bar'][-1] . PHP_EOL;

Expected result:
----------------
3
2
bar



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



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

Reply via email to