Brent 7/18/2024

array_find in PHP 8.4

Read Original

array_find in PHP 8.4 Written on 2024-07-18 PHP 8.4 adds a handful of functions that have been missing for a while: array_find() and its variants. The purpose of array_find() is simple: pass it an array and a callback, and return the first element for which the callback returns true. $numbers = [1, 2, 3, 4, 5, 6]; $firstMatch = array_find( array: $numbers, callback: fn (int $number) => $number % 2

array_find in PHP 8.4

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser