2010/3/16 Felix De Vliegher <felix.devlieg...@gmail.com>: > Hi all > > I recently needed seek functionality in arrays, and couldn't find it in the > regular set of array functions, so I wrote a function for it. (Seek = getting > an array value based on the position (or offset, if you want to call it like > that), and not the key of the item) > > Basically you can use it like this: > $input = array(3, 'bar', 'baz'); > echo array_seek($input, 2); // returns 'baz' > echo array_seek($input, 0); // returns 3 > echo array_seek($input, 5); // returns NULL, emits an out of range warning > > I was wondering if it's useful to add this to the family of array functions. > I know there is a somewhat similar thing in SPL (ArrayIterator::seek), but > that doesn't work exactly like what I was aiming for. > > Attached is a patch for the function against the 5.3 branch. If approved, I > could add it to svn + testcases + docs. Feedback please :-) > > > Kind regards, > Felix
Hi Felix, What about adding a new int parameter to PHP array function: next() and prev() instead of adding a new one? Cheers, Patrick -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php