3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Convert all dashes/underscores into separator $title = "Convert all dashes/underscores into separator"; $separator = "-"; $flip = $separa;tor == '-' ? '_' : '-'; $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); // Remove all characters that are not the separator, letters, numbers, or whitespace. $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title)); // Replace all separator characters and whitespace by a single separator $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); echo trim($title, $separator);
based on L90aq
Output for 7.2.0
Notice: Undefined variable: separa in /in/uattP on line 6 Warning: Use of undefined constant tor - assumed 'tor' (this will throw an Error in a future version of PHP) in /in/uattP on line 6 Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 3 in /in/uattP on line 8
Output for 5.3.19 - 7.1.10
Notice: Undefined variable: separa in /in/uattP on line 6 Notice: Use of undefined constant tor - assumed 'tor' in /in/uattP on line 6 Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 3 in /in/uattP on line 8