3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.4.0 - 5.5.28, 5.5.31 - 5.5.33, 5.6.7 - 5.6.12, 5.6.16 - 5.6.19, 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.4, 7.0.12 - 7.1.0
string(37) "internationalizaetion-is-the-greatest" string(14) "xiang-gang-aao" string(8) "ton-yion" string(19) "ellenike-demokratia"
Output for 7.0.6
Fatal error: Uncaught Error: Call to undefined function iconv() in /in/lcChO:7 Stack trace: #0 /in/lcChO(16): slugify('internationaliz...') #1 {main} thrown in /in/lcChO on line 7
Process exited with code 255.
Output for 5.0.0 - 5.3.29, 5.5.29 - 5.5.30, 5.5.34, 5.6.13 - 5.6.15, 5.6.20, 7.0.5
string(31) "itrntinlizaetin-is-the-greatest" string(0) "" string(0) "" string(0) ""
Output for 5.5.35, 5.6.21
Fatal error: Call to undefined function iconv() in /in/lcChO on line 7
Process exited with code 255.
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.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