3v4l.org

run code in 300+ PHP versions simultaneously
<?php $acceptSpaces = true; $acceptUppercase = true; $text = 'El méu tëst'; // Replace non letter or digits by - $pattern = $acceptSpaces ? '~[^\\pL\d]+~u' : '~[^ \\pL\d]+~u'; $text = preg_replace($pattern, '-', $text); var_dump('preg replace', $text); // Trim $text = trim($text, '-'); var_dump('trim', $text); // Transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); var_dump('transliterate', $text); if(!$acceptUppercase) { // Lowercase $text = strtolower($text); } var_dump('lower', $text); // Remove unwanted characters $pattern = $acceptSpaces ? '~[^ -\w]+~' : '~[^-\w]+~'; $text = preg_replace($pattern, '', $text); var_dump('replace2', $text); var_dump( $text );
Output for git.master, git.master_jit, rfc.property-hooks
string(12) "preg replace" string(13) "El-méu-tëst" string(4) "trim" string(13) "El-méu-tëst" string(13) "transliterate" string(11) "El-m?u-t?st" string(5) "lower" string(11) "El-m?u-t?st" Warning: preg_replace(): Compilation failed: invalid range in character class at offset 6 in /in/gYp9H on line 37 string(8) "replace2" NULL 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:
20.24 ms | 402 KiB | 8 Q