Bitte versuchen auf diese Weise, wird es 100% arbeiten
<?php
$month_arr = array('Jun16','Mar16','Dec16','Jan17','Oct16','Nov16');
/* Convert dates in y-m-d format */
foreach ($month_arr as $key => $ma) {
$output = str_split($ma, 3);
$full_date = $output[1].'-'.date('m', strtotime($output[0])).'-01';
$months[] = $full_date;
}
/* Now sort all dates in DESC order */
$dates = array();
foreach ($months as $u)
{
$dates[] = $u;
}
array_multisort($dates, SORT_DESC, $months);
/* Get latest 3 months */
$last_three_months = array_slice($months, 0, 3);
/* Convert last 3 months into required format */
foreach($last_three_months as $lm)
{
$parsed_last_three_months[] = date('My',strtotime($lm));
}
echo "<pre>";
print_r($parsed_last_three_months);
?>
es Hoffnung funktionieren wird. und lass es mich wissen, wenn es fertig ist :)
Können Sie zeigen, was Sie bereits ausprobiert haben? –
Monat Name String Länge 3 wird behoben werden? –
und Monatsliste wird im String-Format oder im Array-Format sein? –