skip to Main Content

php loop through array and output date and counter

So I have this code: $avaDates = [['date_starts'=>'2024-03-01'],['date_starts'=>'2024-03-09'],['date_starts'=>'2024-04-05'],['date_starts'=>'2024-04-09'],['date_starts'=>'2024-04-15'],['date_starts'=>'2024-05-03']]; $sum = 0; $months = ''; foreach($avaDates as $date){ $monthCheck = substr($date['date_starts'], 0, -3); if($months !== $monthCheck){ $months = $monthCheck; $dateFormat = date("F-Y", strtotime($months)); echo strtolower($dateFormat).' '.$sum."n"; $sum = 0; } $sum…

VIEW QUESTION

Attempt to read property "id" on bool in Laravel 8

I got this data from an external API call. $countries = @file_get_contents('https://external../api/countries'); $countriesArray = json_decode($countries, true); print_r($countriesArray); //dd($countriesArray); Array ( [success] => 1 [message] => countries [data] => Array ( [0] => Array ( [id] => 1 [name] => Afghanistan…

VIEW QUESTION
Back To Top
Search