Reputation: 157
why map
it's not returning or pushing a values into array i tried to use use function
to call my array Emails
but its not working here is my logic code
$emails = []; //emails array
$students = User::where('role','student')->get(); //10 students email
$maps = collect($students)->pluck('email'); //collect 10 students email
$maps->map(function($map) use($emails){
return array_push($emails, $map); //push 10 students email to emails array
});
return $emails; //test emails array
it is returning empty email array i don't know why its not working
Upvotes: 1
Views: 415