3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function scholar_parse_time($time) { if (preg_match('/^\s*(?P<hour>\d+)(?>:(?P<minute>\d+))(?>:(?P<second>\d+(\.\d*)?))?\s*$/', $time, $match)) { print_r($match); } } (scholar_parse_time('0:1')); (scholar_parse_time('0:1:1')); (scholar_parse_time('0:1:1.1')); (scholar_parse_time('0:1:1.'));
Output for 4.3.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => 0:1 [hour] => 0 [1] => 0 [minute] => 1 [2] => 1 ) Array ( [0] => 0:1:1 [hour] => 0 [1] => 0 [minute] => 1 [2] => 1 [second] => 1 [3] => 1 ) Array ( [0] => 0:1:1.1 [hour] => 0 [1] => 0 [minute] => 1 [2] => 1 [second] => 1.1 [3] => 1.1 [4] => .1 ) Array ( [0] => 0:1:1. [hour] => 0 [1] => 0 [minute] => 1 [2] => 1 [second] => 1. [3] => 1. [4] => . )
Output for 4.3.0 - 4.3.2
Array ( [0] => 0:1 [1] => 0 [2] => 1 ) Array ( [0] => 0:1:1 [1] => 0 [2] => 1 [3] => 1 ) Array ( [0] => 0:1:1.1 [1] => 0 [2] => 1 [3] => 1.1 [4] => .1 ) Array ( [0] => 0:1:1. [1] => 0 [2] => 1 [3] => 1. [4] => . )