there's no standard slug function in php. most softwares nowadays comes with function to slug-ify a string to format seo friendly url. but working on a standalone program, this is what i come up with based on some google search results.
PHP:
function to_slug($string) { | |
return preg_replace('/[^a-z\d-]/', '-', strtolower(trim($string))); | |
} |
Leave a comment