3v4l.org

run code in 300+ PHP versions simultaneously
<?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 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
<select name="date"> <option value="12月19日木">12月19日木</option> <option value="12月20日金">12月20日金</option> <option value="12月21日土">12月21日土</option> <option value="12月22日日">12月22日日</option> <option value="12月26日木">12月26日木</option> <option value="12月27日金">12月27日金</option> <option value="12月28日土">12月28日土</option> <option value="12月29日日">12月29日日</option> <option value="12月31日火">12月31日火</option> <option value="1月1日水">1月1日水</option> <option value="1月2日木">1月2日木</option> <option value="1月3日金">1月3日金</option> <option value="1月4日土">1月4日土</option> <option value="1月5日日">1月5日日</option> <option value="1月7日火">1月7日火</option> <option value="1月8日水">1月8日水</option> <option value="1月9日木">1月9日木</option> <option value="1月10日金">1月10日金</option> <option value="1月11日土">1月11日土</option> <option value="1月12日日">1月12日日</option> <option value="1月14日火">1月14日火</option> <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/s1CHF on line 17
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/s1CHF 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/s1CHF 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/s1CHF on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/s1CHF on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/s1CHF on line 12
Process exited with code 255.

preferences:
274.06 ms | 401 KiB | 365 Q