rfc:array_key_first_last_index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:array_key_first_last_index [2016/01/01 20:11] jbaffordrfc:array_key_first_last_index [2016/01/01 20:19] jbafford
Line 15: Line 15:
  
 ===== Proposal ===== ===== Proposal =====
 +Arrays in php are ordered maps, but there is no convenient way to 
 +
 array_key_first() returns the first key in an array. array_key_first() returns the first key in an array.
  
Line 63: Line 65:
  
 With the reference implementation provided below, array_key_first() and array_key_last() directly retrieve the array key from the underlying hash (by setting a local hash pointer to the start/end of the array and retrieving the key for that index). By necessity, array_key_index() iterates through the keys, but does so in C code, rather than in PHP code. With the reference implementation provided below, array_key_first() and array_key_last() directly retrieve the array key from the underlying hash (by setting a local hash pointer to the start/end of the array and retrieving the key for that index). By necessity, array_key_index() iterates through the keys, but does so in C code, rather than in PHP code.
 +
 +In the proposed PR implementing this functionality (see below), array_key_first() and array_key_last() are implemented in terms of array_key_index(); array_key_index() exists a a consequence and extension of generalizing the common code between array_key_first() and array_key_last().
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 91: Line 95:
   - a link to the git commit(s)   - a link to the git commit(s)
   - a link to the PHP manual entry for the feature   - a link to the PHP manual entry for the feature
- 
rfc/array_key_first_last_index.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1