We have an array of pets, with name and species defined.
$dogs = array_filter($pets,
fn($v) => $v["species"]=="Dog");
foreach($dogs as $row) echo $row["name"];
The foreach to display the result seems so wrong after such a beautiful arrow function.
Am I missing something?
2
Answers
or, replacing the foreach loop with implode() and array_column():
The latter would I guess be more strictly functional.
https://www.php.net/manual/en/function.array-filter