3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function createSlug($str, $replace=array(), $delimiter='-') { setlocale(LC_ALL, 'en_US.UTF8'); if( !empty($replace) ) { $str = str_replace((array)$replace, ' ', $str); } $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); $clean = strtolower(trim($clean, '-')); $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); //strip extra slashes $clean = str_replace('/', '-', $clean); return $clean; } echo createSlug("Abbaye de Saint-Martin Cuvée de Noël.");
Output for 5.0.0 - 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.12 - 7.1.0
abbaye-de-saint-martin-cuve-de-nol
Output for 7.0.6
Fatal error: Uncaught Error: Call to undefined function iconv() in /in/B1UEc:8 Stack trace: #0 /in/B1UEc(17): createSlug('Abbaye de Saint...') #1 {main} thrown in /in/B1UEc on line 8
Process exited with code 255.
Output for 5.5.35, 5.6.21
Fatal error: Call to undefined function iconv() in /in/B1UEc on line 8
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<br /> <b>Fatal error</b>: Call to undefined function: iconv() in <b>/in/B1UEc</b> on line <b>8</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<br /> <b>Fatal error</b>: Call to undefined function: iconv() in <b>/in/B1UEc</b> on line <b>8</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Call to undefined function: iconv() in <b>/in/B1UEc</b> on line <b>8</b><br />