[Solved] why nested loop not working in laravel
You have to make another array from your collection. And then you will able to get anything that you need. $result = []; foreach ($users as $u) { $result[ $u-> namecategory ] = $result[ $u-> namecategory ] ?? []; $result[ $u-> namecategory ][$namesubcategory] = $result[ $u-> namecategory ][$namesubcategory] ?? []; $result[ $u-> namecategory ][$namesubcategory][] = … Read more