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
Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 5 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/1oeUF on line 6 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 6 Deprecated: strtr(): Passing null to parameter #1 ($string) of type string is deprecated in /in/1oeUF on line 7 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 10 NULL Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 5 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/1oeUF on line 6 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 6 Deprecated: strtr(): Passing null to parameter #1 ($string) of type string is deprecated in /in/1oeUF on line 7 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 10 NULL Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 5 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/1oeUF on line 6 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 6 Deprecated: strtr(): Passing null to parameter #1 ($string) of type string is deprecated in /in/1oeUF on line 7 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 10 NULL Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 5 Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/1oeUF on line 6 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 6 Deprecated: strtr(): Passing null to parameter #1 ($string) of type string is deprecated in /in/1oeUF on line 7 Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in /in/1oeUF on line 10 NULL

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:
48.73 ms | 409 KiB | 8 Q