3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function createSlug($str, $delimiter = '_'){ $slug = strtolower(trim(preg_replace('/[\s-]+/', $delimiter, preg_replace('/[^A-Za-z0-9-]+/', $delimiter, preg_replace('/[&]/', 'and', preg_replace('/[\']/', '', iconv('UTF-8', 'ASCII//TRANSLIT', $str))))), $delimiter)); return $slug; } print createSlug('New test field 20 New version');
based on 1l9iV
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
new_test_field_20_new_version