<?php
function date_generator($ex_weeks = array(), $ex_DateTimeObjects = array()) {
$kanji_w = array('日', '月', '火', '水', '木', '金', '土');
$now = new DateTime('now', new DateTimezon('Asia/Tokyo'));
for ($i = 2; $i < 30; $i++) {
$current = $now->add(new DateInterval("P{$i}D"));
if (in_array($current->format('w'), $ex_weeks)) {
continue;
}
foreach ($ex_DateTimeObjects as $object) {
if (!$object->diff($current)->days) {
continue 2;
}
}
$w = $kanji_w[$current->format('w')];
yield $current->format('n月j日') . $w;
}
}
?>
<select name="date">
<?php foreach (date_generator(array(1), array(new DateTime('12/25'))) as $value): ?>
<option value="<?=$value?>"><?=$value?></option>
<?php endforeach; ?>
</select>
preferences:
36.43 ms | 402 KiB | 5 Q