Puoi utilizzare https://php.net/array_map per fare quello che ti serve.