Re: [RFC] array_search_range

From: Date: Fri, 14 Aug 2026 21:09:47 +0000
Subject: Re: [RFC] array_search_range
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-132224@lists.php.net to get a copy of this message
Hi Sjoerd, Thanks for pointing that out. You're absolutely right - LimitIterator does provide similar functionality, but as you noted, it can't be passed to array_search() or other array_* functions. This is exactly the gap array_search_range() fills. It gives users a simple, direct way to search within a range of an array without needing to convert to iterators, manually loop, or create temporary arrays with array_slice(). Best, Sepehr On جمعه ۱۴ اوت ۲۰۲۶، ۲۳:۲۴ Sjoerd Langkemper <sjoerd-php@linuxonly.nl> wrote: > On Fri, Aug 14, 2026, at 20:32, Rowan Tommins [IMSoP] wrote: > > At heart, an ArraySlice object would just be a holder for those three > values, plus a bit of code to iterate over that subset. Custom syntax would > be nice, but easy to add later. > > Thinking about it, it ought to be trivial to build something on top of > ArrayIterator, which already has a seek() method to jump to the start > point. Which brings back a frequent debate about how the array_* functions > should interact with iterators in general - should it actually be: > > iter_search(new ArraySliceIterator($arr, 10, 42), true) > > > LimitIterator (https://www.php.net/manual/en/class.limititerator.php) > more or less does this. But as you said, you cannot pass this to > array_search, because that expects an array. > > Regards, > > Sjoerd > >

« previous php.internals (#132224) next »