3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filenameNew = 'PX20170713_103320_2651093_00001'; $filenameOld = '5956e5781e4f1-20170630_233347_5712837_00001.xml'; //$timeslug = implode(array_slice(explode('_', rtrim(basename($fileToProcess), ".xml" )), 0, 2)); //$datetime = date('c', strtotime($timeslug)); function getDateFromFilename(string $filename) { $filename = ltrim($filename, 'PX'); $parts = explode('_', $filename); return $parts; } var_dump(getDateFromFilename($filenameNew));
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
array(4) { [0]=> string(8) "20170713" [1]=> string(6) "103320" [2]=> string(7) "2651093" [3]=> string(5) "00001" }
Output for 5.6.38
Catchable fatal error: Argument 1 passed to getDateFromFilename() must be an instance of string, string given, called in /in/ohWEF on line 17 and defined in /in/ohWEF on line 9
Process exited with code 255.

preferences:
181.85 ms | 401 KiB | 248 Q