PHP provides many array functions: count for the size, in_array to search for a value, array_map to transform, array_filter to filter, array_merge to merge, sort and usort to sort. Many take a callback function.
Example
$carres = array_map(fn($n) => $n * $n, [1, 2, 3]);