A function that will strip all the unsafe characters from a string in order to make it valid for URLs. This can be especially useful when you create your own URLs dynamically using mod_rewrite.
1. function StripUrl($title)
2. {
3. $title = str_replace("#", "sharp", $title);
4. $title = str_replace("/", "or", $title);
5. $title = str_replace("$", "", $title);
6. $title = str_replace("&", "and", $title);
7. $title = str_replace("&", "and", $title);
8. $title = str_replace("+", "plus", $title);
9. $title = str_replace(",", "", $title);
10. $title = str_replace(":", "", $title);
11. $title = str_replace(";", "", $title);
12. $title = str_replace("=", "equals", $title);
13. $title = str_replace("?", "", $title);
14. $title = str_replace("@", "at", $title);
15. $title = str_replace("<", "", $title);
16. $title = str_replace(">", "", $title);
17. $title = str_replace("%", "", $title);
18. $title = str_replace("{", "", $title);
19. $title = str_replace("}", "", $title);
20. $title = str_replace("|", "", $title);
21. $title = str_replace("\\", "", $title);
22. $title = str_replace("^", "", $title);
23. $title = str_replace("~", "", $title);
24. $title = str_replace("[", "", $title);
25. $title = str_replace("]", "", $title);
26. $title = str_replace("`", "", $title);
27. $title = str_replace("'", "", $title);
28. $title = str_replace("\", "", $title);
29. $title = str_replace("_", "-", $title);
30. $title = str_replace(" ", "-", $title);
31. return $title;
32. }