PHP ships dozens of array helpers. Learn the ones you will reach for daily before memorizing edge cases.
Transform and filter
array_map(fn($x) => ..., $arr)— transform each elementarray_filter($arr, fn($x) => ...)— keep matching elementsarray_reduce— fold to a single value
Search and sort
in_array($needle, $haystack, true)— strict third arg recommendedarray_search,sort,asort,ksort
Combine and slice
array_merge, array_slice, array_column (extract one field from rows), array_unique.
Self-check
- Why pass
trueas the third argument toin_array? - Which function extracts all
emailkeys from an array of users?