3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function date_generator($ex_weeks = array(), $ex_DateTimeObjects = array()) { $kanji_w = array('日', '月', '火', '水', '木', '金', '土'); $current = new DateTime('now', new DateTimezone('Asia/Tokyo')); for ($i = 0; $i < 30; $i++) { $current->add(new DateInterval('P1D')); if ($i < 2 || 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>
Output for 5.5.0 - 7.1.0
<select name="date"> Notice: Undefined index: (4) in /in/ntPVH on line 16 <option value="12月19日">12月19日</option> Notice: Undefined index: (5) in /in/ntPVH on line 16 <option value="12月20日">12月20日</option> Notice: Undefined index: (6) in /in/ntPVH on line 16 <option value="12月21日">12月21日</option> Notice: Undefined index: (0) in /in/ntPVH on line 16 <option value="12月22日">12月22日</option> Notice: Undefined index: (4) in /in/ntPVH on line 16 <option value="12月26日">12月26日</option> Notice: Undefined index: (5) in /in/ntPVH on line 16 <option value="12月27日">12月27日</option> Notice: Undefined index: (6) in /in/ntPVH on line 16 <option value="12月28日">12月28日</option> Notice: Undefined index: (0) in /in/ntPVH on line 16 <option value="12月29日">12月29日</option> Notice: Undefined index: (2) in /in/ntPVH on line 16 <option value="12月31日">12月31日</option> Notice: Undefined index: (3) in /in/ntPVH on line 16 <option value="1月1日">1月1日</option> Notice: Undefined index: (4) in /in/ntPVH on line 16 <option value="1月2日">1月2日</option> Notice: Undefined index: (5) in /in/ntPVH on line 16 <option value="1月3日">1月3日</option> Notice: Undefined index: (6) in /in/ntPVH on line 16 <option value="1月4日">1月4日</option> Notice: Undefined index: (0) in /in/ntPVH on line 16 <option value="1月5日">1月5日</option> Notice: Undefined index: (2) in /in/ntPVH on line 16 <option value="1月7日">1月7日</option> Notice: Undefined index: (3) in /in/ntPVH on line 16 <option value="1月8日">1月8日</option> Notice: Undefined index: (4) in /in/ntPVH on line 16 <option value="1月9日">1月9日</option> Notice: Undefined index: (5) in /in/ntPVH on line 16 <option value="1月10日">1月10日</option> Notice: Undefined index: (6) in /in/ntPVH on line 16 <option value="1月11日">1月11日</option> Notice: Undefined index: (0) in /in/ntPVH on line 16 <option value="1月12日">1月12日</option> Notice: Undefined index: (2) in /in/ntPVH on line 16 <option value="1月14日">1月14日</option> Notice: Undefined index: (3) in /in/ntPVH on line 16 <option value="1月15日">1月15日</option> </select>
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '$current' (T_VARIABLE) in /in/ntPVH on line 17
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/ntPVH on line 17
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_VARIABLE in /in/ntPVH on line 17
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/ntPVH on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/ntPVH on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/ntPVH on line 12
Process exited with code 255.