3v4l.org

run code in 300+ PHP versions simultaneously
<?php public function sanitiseFilename($input) { // // See #3271 // Code from http://stackoverflow.com/a/2021729/3929494 // // Remove anything which isn't a word, whitespace, number // or any of the following characters -_~,;:[](). // If you don't need to handle multi-byte characters // you can use preg_replace rather than mb_ereg_replace // Thanks @Łukasz Rysiak! $output = mb_ereg_replace("([^\w\s\d\-_~,;:\[\]\(\).])", '', $input); // Remove any runs of periods (thanks falstro!) $output = mb_ereg_replace("([\.]{2,})", '', $output); // Remove any runs of spaces, e.g. " / " becomes " " which is ugly $output = mb_ereg_replace(" ", " ", $output); return $output; } echo sanitiseFilename("BBC/TVL") . PHP_EOL; echo sanitiseFilename("This%%% is an an$57noy£ing string/ to / use") . PHP_EOL; ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.00.0170.08020.14
5.6.160.0030.04020.73
5.6.150.0070.08018.25
5.6.140.0070.05318.17
5.6.130.0100.05318.16
5.6.120.0070.09020.94
5.6.110.0100.07021.09
5.6.100.0030.07021.13
5.6.90.0030.04021.00
5.6.80.0130.06020.50
5.5.300.0100.05017.99
5.5.290.0130.06317.98
5.5.280.0170.07320.77
5.5.270.0100.06320.94
5.5.260.0070.07320.72
5.5.250.0100.08020.68
5.5.240.4170.04020.25

preferences:
142.5 ms | 1386 KiB | 7 Q