Reputation: 1340
So I've retrieved an object from angular and need to convert it to an array.
The below works but I'm wondering if there's a cleaner or more efficient way to do this with Laravel:
$array = array();
foreach($input as $i){
$array[] = $i['brand_name'];
}
Thanks!
Upvotes: 0
Views: 52
Reputation: 12189
You can do it in one line:
$array = array_only($input, array('brand_name'));
if you need more than one value:
$array = array_only($input, array('brand_name', 'address'));
Upvotes: 1