3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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; ?>
based on iHfNj
Output for 5.0.4 - 7.1.0
Notice: Undefined variable: phone in /in/BSJrJ on line 22 Notice: Undefined variable: timestamp in /in/BSJrJ on line 23
Output for 4.3.10 - 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