3v4l.org

run code in 300+ PHP versions simultaneously
<?php function slugify($str, $maxLength = null, $separator = '-') { if(function_exists('transliterator_transliterate')) { $str = transliterator_transliterate("Any-Latin; Latin-ASCII; Lower()", $str); } $str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str); $str = preg_replace('/[^a-zA-Z0-9\/_|\'\. -]/', '', $str); if($maxLength !== null) { substr($str, 0, $maxLength); } $str = preg_replace('/[\/_| -]+/', $separator, $str); return trim(strtolower($str), $separator); } var_dump(slugify('Iñtërnâtiônàlizætiøn - is the greatest! ')); var_dump(slugify(' ^*_:香港 åä?ö ')); var_dump(slugify('των υιών')); var_dump(slugify('Ελληνική Δημοκρατία'));
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
string(37) "internationalizaetion-is-the-greatest" string(14) "xiang-gang-aao" string(8) "ton-yion" string(19) "ellenike-demokratia"
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33, 8.0.13
Fatal error: Uncaught Error: Call to undefined function iconv() in /in/lcChO:7 Stack trace: #0 /in/lcChO(16): slugify('I\xC3\xB1t\xC3\xABrn\xC3\xA2ti\xC3\xB4n...') #1 {main} thrown in /in/lcChO on line 7
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Fatal error: Call to undefined function iconv() in /in/lcChO on line 7
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
string(31) "itrntinlizaetin-is-the-greatest" string(0) "" string(8) "ton-yion" string(19) "elliniki-dimokratia"
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: iconv() in /in/lcChO on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: iconv() in /in/lcChO on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: iconv() in /in/lcChO on line 7

preferences:
249.36 ms | 401 KiB | 465 Q