我敢打赌,我可以,但会这样工作吗?我可以使用多条件的if语句吗? PHP
function dutchDateNames($) {
$day = explode('-', $date)[2];
$dutchday = ($day < 10) ? substr($day, 1) : $day;
$month = explode('-', $date)[1];
if ($month == '01' . '02') {
$dutchmonth = 'Januari' . 'Februari';
}
$dutchdate = $dutchday . ' ' . $dutchmonth . ' ' . explode('-', $date)[0];
return $dutchdate
}
所以,如果$month
是01,$ dutchmonth应该Januari。如果$ month是02,$ dutchmonth应该是Februari,依此类推。 我有这种感觉,我没有这样做的权利?
使用'switch'而不是'if' http://php.net/manual/en/control-structures.switch.php – JapanGuy
为什么不使用'switch' case? –