代码运行完美,但由于我在重复自己(我喜欢在编程时避免),我想知道这是否可以写得更短/更好?
$start = getLocaleDate($item[0]['start_day']);
$start = $start['day_int'] . ' ' . $start['month_string'];
if ($item[0]['start_houre'] !== '00:00:00') {
$houre = stripLeadingZero(substr($item[0]['start_houre'], 0, 2));
$minute = substr($item[0]['start_houre'], 3, 2);
$start .= ' at' . $houre . 'u' . $minute;
}
$end = getLocaleDate($item[0]['end_day']);
$end = $end['day_int'] . ' ' . $end['month_string'];
if ($item[0]['end_houre'] !== '00:00:00') {
$houre = stripLeadingZero(substr($item[0]['end_houre'], 0, 2));
$minute = substr($item[0]['end_houre'], 3, 2);
$end .= ' at' . $houre . 'u' . $minute;
}