Req #55095 [Bgs]: idea/request for new array_function

From: Date: Fri, 01 Jul 2011 07:02:31 +0000
Subject: Req #55095 [Bgs]: idea/request for new array_function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161444@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55095&edit=1

 ID:                 55095
 User updated by:    anticom at hotmail dot de
 Reported by:        anticom at hotmail dot de
 Summary:            idea/request for new array_function
 Status:             Bogus
 Type:               Feature/Change Request
 Package:            Arrays related
 Operating System:   Windows Vista 32Bit
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Thank you rasmus :)


Previous Comments:
------------------------------------------------------------------------
[2011-07-01 00:40:33] rasmus@php.net

Or if you are worried about the size of the array, just slice it. This works 
nicely in older PHP versions as well:

// Get 1 key starting at position 2 of $arr
echo key(array_slice($arr, 2, 1, true));

------------------------------------------------------------------------
[2011-07-01 00:35:57] rasmus@php.net

echo array_keys($arr)[1];  // PHP 5.4

------------------------------------------------------------------------
[2011-06-30 23:42:02] anticom at hotmail dot de

Description:
------------
I realy would prefer a function for associative arrays, enableing to get an index-specific key.

This would be usefull especialy for big array's, so you have to iterate through them, to get a
specific key. The other advantage would be, that you could iterate through the array manually with a
for-loop, without having to store all the key's in a temporary array using array_keys()

Test script:
---------------
<?php
$arr = array("foo" => 'bar', "secondFoo" => 'anyval');
echo array_getKeyAt($arr, 1);
?>

Expected result:
----------------
output would be:
secondFoo

Actual result:
--------------
[function not implemented yet afaik]


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



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


Thread (4 messages)

« previous php.bugs (#161444) next »