3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function slugify($text) { if (empty($text)) return null; $text = strtr(utf8_decode($text), utf8_decode('ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƒƠơƯưǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǺǻǼǽǾǿ'), 'AAAAAAAECEEEEIIIIDNOOOOOOUUUUYsaaaaaaaeceeeeiiiinoooooouuuuyyAaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKkLlLlLlLlllNnNnNnnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzsfOoUuAaIiOoUuUuUuUuUuAaAEaeOo'); // 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); return $text; } echo slugify("João dos Santos Videira");
Output for 5.0.5 - 5.5.34, 5.6.0 - 5.6.20, 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.5, 7.0.14 - 7.1.0
Joao_dos_Santos_Videira
Output for 7.0.6 - 7.0.10
Fatal error: Uncaught Error: Call to undefined function iconv() in /in/61WdN:18 Stack trace: #0 /in/61WdN(23): slugify('Joao_dos_Santos...') #1 {main} thrown in /in/61WdN on line 18
Process exited with code 255.
Output for 5.5.35 - 5.5.38, 5.6.21 - 5.6.25
Fatal error: Call to undefined function iconv() in /in/61WdN on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/61WdN on line 12
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: iconv() in /in/61WdN on line 18
Process exited with code 255.
Output for 4.4.0 - 4.4.4
Fatal error: Call to undefined function: iconv() in /in/61WdN on line 18
Process exited with code 255.
Output for 4.3.11
Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/61WdN on line 12 Fatal error: Call to undefined function: iconv() in /in/61WdN on line 18
Process exited with code 255.
Output for 4.3.2 - 4.3.10
Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/61WdN on line 12 Fatal error: Call to undefined function: iconv() in /in/61WdN on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/61WdN on line 12 Fatal error: Call to undefined function: iconv() in /in/61WdN on line 18