[php-src] PR #23325: Add array_search_range() function

From: Date: Sun, 16 Aug 2026 19:07:26 +0000
Subject: [php-src] PR #23325: Add array_search_range() function
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-37935@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/23325 Author: sepehrphpr Add array_search_range() function This PR adds a new array_search_range() function to the PHP standard library. Function signature array_search_range(mixed $needle, array $haystack, int $offset = 0, ?int $length = null, bool $strict = false): int|string|false Description array_search_range() searches a portion of the array for a given value and returns the first corresponding key if successful, or false if not found. It extends the existing array_search() function with two additional parameters: $offset — Start searching from this position (0-indexed). Negative values count from the end of the array. $length — Limit the search to this many elements after $offset. If null, searches to the end of the array. Examples $array = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 2, 'e' => 1]; array_search_range(2, $array); // "b" array_search_range(2, $array, 2); // "d" array_search_range(2, $array, 0, 2); // "b" array_search_range(1, $array, -2); // "e"

« previous php.git-pulls (#37935) next »