3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "duls~ao vafan"; $separator = '_'; $text = preg_replace('/[^\\pL\d]+/u', $separator, $text); if(function_exists('iconv')){ setlocale(LC_CTYPE, 'fr_FR.UTF-8'); $text = iconv('UTF-8','ASCII//TRANSLIT//IGNORE',$text); } $text = strtolower($text); $text = preg_replace('/[^-\w]+/', $separator, $text); $text = trim($text, '-_ '); echo $text;

preferences:
29.43 ms | 402 KiB | 5 Q