array_map inline anonymous function array_map inline anonymous function php php

array_map inline anonymous function


I hope this will help:

$user_meta = array_map(function ($a) { return $a[0]; }, $user_meta);


There's nothing wrong with the array_map line, but everything before it is wrong. That is the output of a print_r not PHP code. Compare how you define the array in the two links you posted.


That's not an answer to your question, but since you want to return the first key of each sub-array, you can just use array_column.

$user_meta = array_column($user_meta, 0);