Question

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']; 

    }
Was it helpful?

Solution

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']; 
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top