I would like to know how to convert a post title (or string) to url
You can use wordpress function sanitize_title. When you pass the post title or string, the function will return sanitized string.
To create the file name portion of a URL the same way that WordPress does use this:
$newurl = sanitize_title('How To Convert WordPress Post Title To Url'); echo $newurl;