I am programming a blog and I want the URIs to be the title like the question title here in stackoverflow or like wordpress. What are the rules for sanitizing a URI? Is there an already made code in PHP that does this?
Thanks in advance, Omer
This might be the shortest way to replace any non alphanumeric character with a single hyphen:
trim(preg_replace('/[^a-z0-9-]+/', '-', strtolower($str)), '-')
1.4m articles
1.4m replys
5 comments
57.0k users