can you please help me in using closures. I'm using laravel's collection filter to check unique emails. The code below should fill the $unique_email
array inside the filter function. Is there's a problem on how i used the pass by reference? Thanks in advance.
$unique_email = array();
$users->filter(function ($user) use (&$unique_email) {
if( !in_array( $user->email , $unique_email ) ) {
return $unique_email[] = $user->email;
}
});
dd($unique_email); //returns empty array
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire