- var_dump: documentation ( source)
- preg_replace: documentation ( source)
- strtolower: documentation ( source)
<?php
$strings = array(
'this is a string',
'this is $ a string',
'this is 12 string',
'this is $12.99 string',
);
foreach ($strings as $string) {
var_dump(strtolower(preg_replace('#[-+]#', '-', preg_replace('#[^a-z0-9\-]#', '', preg_replace('#[\s+]#', '-', $string)))));
}