3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filename = "2053839077_On_10_15_2014_By_d.willard@10_58_30 PM"; $r2 = "/(?P<phone>\d{10})_On_(?P<m>\d{1,2})_(?P<d>\d{1,2})_(?P<Y>\d{4})_By_.*@(?P<h>\d{1,2})_(?P<i>\d{1,2})_(?P<s>\d{1,2}) (?P<ampm>AM|PM])/"; if (preg_match($r2, $filename, $bits)) { $phone = $bits['phone']; $hour = $bits['h']; if ($bits['ampm'] == 'PM') { $hour += 12; } $year = $bits['Y']; $month = sprintf('%02s', $bits['m']); $day = sprintf('%02s', $bits['d']); $hour = sprintf('%02s', $hour); $min = sprintf('%02s', $bits['i']); $sec = sprintf('%02s', $bits['s']); $timestamp = "$year-$month-$day $hour:$min:$sec"; } echo $phone.PHP_EOL; echo $timestamp; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $phone in /in/BSJrJ on line 22 Warning: Undefined variable $timestamp in /in/BSJrJ on line 23
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: phone in /in/BSJrJ on line 22 Notice: Undefined variable: timestamp in /in/BSJrJ on line 23
Output for 7.3.32 - 7.3.33
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.9, 5.0.2 - 5.0.3
Notice: Undefined variable: phone in /in/BSJrJ on line 22 Notice: Undefined variable: timestamp in /in/BSJrJ on line 23
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Undefined variable: phone in /in/BSJrJ on line 22 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/BSJrJ on line 22 PHP_EOL Notice: Undefined variable: timestamp in /in/BSJrJ on line 23

preferences:
238.98 ms | 402 KiB | 348 Q