3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sanitizeFilename($name) { $res = preg_replace('#\w:\s#', ' - ', $name); $res = preg_replace('#\s:\s#', '', $res); $res = strtr($res, [ '<' => '-', '>' => '-', ':' => '-', '"' => '', '/' => '-', '\\' => '-', '|' => '-', '?' => '', '*' => '-' ]); $res = preg_replace('#\s{2,}#', ' ', $res); return $res; } var_dump(sanitizeFilename('The Hobbit: an unexpected')); var_dump(sanitizeFilename('The Hobbit:forever')); var_dump(sanitizeFilename('The Hobbit 50:50')); var_dump(sanitizeFilename('The Hobbit 50 : 50'));
Output for git.master, git.master_jit, rfc.property-hooks
string(25) "The Hobbi - an unexpected" string(18) "The Hobbit-forever" string(16) "The Hobbit 50-50" string(15) "The Hobbit 5050"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.01 ms | 401 KiB | 8 Q