Convert Collection to Array in Few Lines

Submitted by kmlnyk - 4 years ago

Its Diffucult to convert whole object to an array . Normally we are Doing it By Iterate through foreach. By using Below Code we will reduce amount of line of code

  $data Would be the Collection object which we want to convert
$result = array_map(function($object){
                        return (array) $object;
                       }, $data);