Reputation: 783
At first I had this (work in wamp but not in my web server)
$ids = array_map(function($item) { return $item['user_id']; }, $data['student_teacher']);`
So I try to convert the code to that but nothing work ( i got Array,Array,Array,Array,Array,Array from outpout )
$ids = array_map($this->myarraymap(null), $data['student_teacher']);
function myarraymap($item) {
return $item['user_id'];
}
Upvotes: 2
Views: 1723
Reputation: 5084
You need to pass it a callback, and not actually pass it the execution of the function, i.e.,
$ids = array_map(array($this, 'myarraymap'), $data['student_teacher']);
function myarraymap($item) {
return $item['user_id'];
}
Upvotes: 7