Re: [RFC] array_search_range
| From: | Rowan Tommins [IMSoP] | Date: | Fri, 14 Aug 2026 18:32:22 +0000 |
| Subject: | Re: [RFC] array_search_range | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-132222@lists.php.net to get a copy of this message | ||
Hi Sepehr,
On 14 August 2026 18:03:18 BST, "سپهر محمودی" <sepehrphpr@gmail.com>
wrote:
>Right now, ArraySlice doesn't exist in PHP. It's an interesting idea,
>but it has no RFC, no implementation, and no timeline. We don't know
>when or if it will happen.
I understand what you mean, but it feels quite premature to make that judgement - this discussion
has been going for less than two days, and there's a whole year to get a feature into 8.7
(it's already too late for 8.6).
I don't know the details of the implementation of either feature, but it doesn't feel like
there's that much extra. At the core, you need some code somewhere that takes an array and two
ints, and iterates that slice of the array.
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)
I think it's worth exploring these different options, if only to rule them out as too
difficult.
(PS Again: please post replies below quoted text, not above it.)
Regards,
Rowan Tommins
[IMSoP]