3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = ["date: march 27, 2017", "start: 12:30pm"]; foreach ($strings as $i => $string) { for ($i = 0; $i < 6; ++$i) { printf( "%d: %s BECOMES %s\n", $i, match($i) { 0 => ($pos = strpos($string, ": ")) ? substr($string, $pos + 2) : $string, 1 => ($sub = strstr($string, ": ")) ? substr($sub, 2) : $string, 2 => explode(': ', $string, 2)[1], 3 => array_slice(explode(': ', $string, 2), -1)[0], 4 => preg_replace('/(^.*?:\s)/', '', $string), 5 => preg_match("/^.*?:\s\K.*/", $string, $m) ? $m[0]: $string }, $string ); } }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
0: march 27, 2017 BECOMES date: march 27, 2017 1: march 27, 2017 BECOMES date: march 27, 2017 2: march 27, 2017 BECOMES date: march 27, 2017 3: march 27, 2017 BECOMES date: march 27, 2017 4: march 27, 2017 BECOMES date: march 27, 2017 5: march 27, 2017 BECOMES date: march 27, 2017 0: 12:30pm BECOMES start: 12:30pm 1: 12:30pm BECOMES start: 12:30pm 2: 12:30pm BECOMES start: 12:30pm 3: 12:30pm BECOMES start: 12:30pm 4: 12:30pm BECOMES start: 12:30pm 5: 12:30pm BECOMES start: 12:30pm
Output for 7.4.0 - 7.4.33
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/aLEVl on line 10
Process exited with code 255.

preferences:
121.14 ms | 407 KiB | 5 Q