3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function slugify($text) { if (empty($text)) return null; $text = strtr(utf8_decode($str), 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, 7.0.0 - 7.0.5, 7.0.14 - 7.1.0
Notice: Undefined variable: str in /in/6mZUu on line 9
Output for 7.0.6 - 7.0.10
Notice: Undefined variable: str in /in/6mZUu on line 9 Fatal error: Uncaught Error: Call to undefined function iconv() in /in/6mZUu:18 Stack trace: #0 /in/6mZUu(23): slugify('') #1 {main} thrown in /in/6mZUu on line 18
Process exited with code 255.
Output for hhvm-3.12.0
Notice: Undefined variable: str in /in/6mZUu on line 9 Warning: utf8_decode() expects parameter 1 to be string, null given in /in/6mZUu on line 9 Warning: strtr() expects parameter 1 to be string, null given in /in/6mZUu on line 9
Output for 5.5.35 - 5.5.38, 5.6.21 - 5.6.25
Notice: Undefined variable: str in /in/6mZUu on line 9 Fatal error: Call to undefined function iconv() in /in/6mZUu on line 18
Process exited with code 255.
Output for 5.0.4
Notice: Undefined variable: str in /in/6mZUu on line 9 Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/6mZUu on line 12
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: str in /in/6mZUu on line 9 Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/6mZUu on line 12
Output for 4.4.5 - 4.4.9
Notice: Undefined variable: str in /in/6mZUu on line 9 Fatal error: Call to undefined function: iconv() in /in/6mZUu on line 18
Process exited with code 255.
Output for 4.4.0 - 4.4.4
Notice: Undefined variable: str in /in/6mZUu on line 9 Fatal error: Call to undefined function: iconv() in /in/6mZUu on line 18
Process exited with code 255.
Output for 4.3.11
Notice: Undefined variable: str in /in/6mZUu on line 9 Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/6mZUu on line 12 Fatal error: Call to undefined function: iconv() in /in/6mZUu on line 18
Process exited with code 255.
Output for 4.3.2 - 4.3.10
Notice: Undefined variable: str in /in/6mZUu on line 9 Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/6mZUu on line 12 Fatal error: Call to undefined function: iconv() in /in/6mZUu on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Undefined variable: str in /in/6mZUu on line 9 Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 3 in /in/6mZUu on line 12 Fatal error: Call to undefined function: iconv() in /in/6mZUu on line 18