+1
Currently there is no way to get a key from an array without either moving the cursor or first getting all keys and go from there. While these function are easily written in PHP, the implementation feels more like a dirty workaround than a solid solution. I would personally use these functions and I think many others will as well, so they are worth being included.

Arnold


Antony Dovgal schreef:
On 01/05/2007 08:49 AM, John Bafford wrote:
Hello,

Attached is a patch and corresponding test file I would like to submit for inclusion in PHP. I would like this patch to be included in PHP 5.2.1, as it is entirely new code (and thus shouldn't cause regressions), but as RC2 was just released earlier today, I understand if it must wait until PHP 5.2.2.

This patch implements three new functions, as described below.

mixed array_key_index(array input, int index [, mixed value])
    Return the array's index'th key (and optionally, value)

mixed array_first(array input [, mixed value])
    Return the array's first key (and optionally, value)
    This is equivalent to array_key_index($input, 0 [, $value]);

mixed array_last(array input [, mixed value])
    Return the array's last key (and optionally, value)
    This is equivalent to array_key_index($input, -1 [, $value]);

-1
Implementing these functions _in_ PHP can't take more than a minute.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to