bit confused on how to do this.
array:3 [▼
0 => array:2 [▼
"id" => 35
"days_left" => "21"
]
1 => array:2[▼
"id" => 40
"days_left" => "14"
]
2 => array:2[▼
"id" => 57
"days_left" => "15"
]
]
I want the array to be ordered by ascending order based on the days left.
$upcoming_b = [];
foreach ($birthday as $key => $value){
$day = Carbon::parse($value->birth_date);
if(Carbon::now()->day <= $day->day){
$upcoming_b[$key]['id'] = $value->id;
$day_of_birth = $day->day;
$today = Carbon::now()->day;
$days_left = (int)$day_of_birth - (int)$today;
$upcoming_b[$key]['days_left'] = $days_left;
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire