3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function slugify($text) { // replace non letter or digits by - $text = preg_replace('~[^\\pL\d]+~u', '-', $text); // trim $text = trim($text, '-'); // transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); // lowercase $text = strtolower($text); // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); if (empty($text)) { return 'n-a'; } return $text; } echo slugify('šđčćž ŠĐČĆŽ') ?>
based on m65u5
Output for 5.3.22 - 5.5.34, 5.6.8 - 5.6.20, 5.6.28 - 7.0.5, 7.0.20 - 7.2.0
-
Output for 7.0.6
Fatal error: Uncaught Error: Call to undefined function iconv() in /in/rV9pM:11 Stack trace: #0 /in/rV9pM(27): slugify('\xC5\xA1\xC4\x91\xC4\x8D\xC4\x87\xC5\xBE-\xC5\xA0\xC4\x90...') #1 {main} thrown in /in/rV9pM on line 11
Process exited with code 255.
Output for 5.5.35, 5.6.21
Fatal error: Call to undefined function iconv() in /in/rV9pM on line 11
Process exited with code 255.