/ Published in: PHP
converts @ to at and & to and
removes anything that isn't alphanumeric
replaces all spaces with -
extra check to ensure there is no doubling up of --'s in final result
removes anything that isn't alphanumeric
replaces all spaces with -
extra check to ensure there is no doubling up of --'s in final result
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getURI($url) { $cleanURL = str_replace(" ",'-',ucwords(preg_replace('/[^a-zA-Z0-9 ]/', "", str_replace(array('&','@'),array('and','at'),trim($url))))); while (strpos($cleanURL,'--') > 0) { $cleanURL = str_replace('--','-',$cleanURL); } // get rid of any excess -'s return $cleanURL; }