laravel array index code example
Example 1: laravel take value from different array by key
$array = array(
array('developer' => array('name' => 'Taylor')),
array('developer' => array('name' => 'Dayle')),
);
$array = array_fetch($array, 'developer.name');
// array('Taylor', 'Dayle');
Example 2: laravel return a single dimensional array
$catcount = 2;
$parents_ids = [];
for ($i = 0; $i < $catcount; $i++) {
$parents_ids[] = $userCategory[$i];
}
$subCats = Category::whereIn('parent_id', $parents_ids)->pluck('id');