3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $filename = "9567567208_2014-10-16_12-16-02_1137592.wav"; $r = '/(?P<phone>\d{10})_(?P<Y>\d{4})-(?P<m>\d{2})-(?P<d>\d{2})_(?P<H>\d{2})-(?P<i>\d{2})-(?P<s>\d{2})_.*/'; if (preg_match($r, $filename, $bits)) { $phone = $bits['phone']; $year = $bits['Y']; $month = sprintf('%02s', $bits['m']); $day = sprintf('%02s', $bits['d']); $hour = sprintf('%02s', $bits['H']); $minute = sprintf('%02s', $bits['i']); $second = sprintf('%02s', $bits['s']); $timestamp = "$year-$month-$day $hour:$minute:$second"; } echo $timestamp.PHP_EOL; echo $phone.PHP_EOL; ?>
based on UphBO
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
2014-10-16 12:16:02 9567567208
Output for 4.3.3 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/p1VAO on line 15 2014-10-16 12:16:02PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/p1VAO on line 16 9567567208PHP_EOL
Output for 4.3.0 - 4.3.2
Notice: Undefined index: phone in /in/p1VAO on line 5 Notice: Undefined index: Y in /in/p1VAO on line 6 Notice: Undefined index: m in /in/p1VAO on line 7 Notice: Undefined index: d in /in/p1VAO on line 8 Notice: Undefined index: H in /in/p1VAO on line 9 Notice: Undefined index: i in /in/p1VAO on line 10 Notice: Undefined index: s in /in/p1VAO on line 11 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/p1VAO on line 15 -00-00 00:00:00PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/p1VAO on line 16 PHP_EOL