2

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

    }
1
  • This is PHP-specific, not CodeIgniter-specific issue. Commented Nov 21, 2011 at 17:10

1 Answer 1

7

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']; 
}
Sign up to request clarification or add additional context in comments.

1 Comment

Glad it worked. Don't forget to accept answers if you found them helpful :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.