- date: documentation ( source)
- strtotime: documentation ( source)
- strtolower: documentation ( source)
<?php
$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']
];
$result = [];
foreach ($avaDates as ['date_starts' => $d]) {
$FY = date("F-Y", strtotime($d));
$result[$FY] = ($result[$FY] ?? 0) + 1;
}
foreach ($result as $fy => $count) {
echo strtolower("$fy $count\n");
}