skip to Main Content

How to iterate an array to count elements PHP?

I wanna know how to iterate an array to count elements in PHP, I've trying next, foreach ($items as $item) { $tm[$item->provider->name] = []; foreach ($items as $item) { $tm[$item->provider->name][$item->product->brand->name] = isset($tm[$item->provider->name][$item->product->brand->name]) ? $tm[$item->provider->name][$item->product->brand->name] + 1 : $tm[$item->provider->name][$item->product->brand->name] = 1;…

VIEW QUESTION

Grouping a collection IN LARAVEL

I have an array called $customerRecords. I want to group the data in this array by the customer's email. This is the array below $customerRecords = [ { "id": 1, "note": "This is note 1", "customer": [ { "id": 1,…

VIEW QUESTION
Back To Top
Search