CakePHP's built in Inflector
class comes with a few handy methods, one of which is the slug
method that lets you convert strings to SEO friendly URLs. The first parameter is the string to convert, the second is the delimiter used to separate each word.
<?php
$str = "This is the string I want to convert";
echo Inflector::slug($str, '-');
?>
Outputs
This-is-the-string-I-want-to-convert