Generic way to sanitize url by stripping any special char
Written by Ioan CHIRIAC
Related protips
2 Responses
OK, great. Now try to transform this 'sanitized' URL back?
Some religious rules disallow you use urlencode()?
By the way, do you happen to know this guy?)
https://coderwall.com/p/a-viza
over 1 year ago
·
@dimasmagadan Hi,
The short answer for not using urlencode is yes, I know about it and I don't want to use it.
For more explanations, the reason is that I need to build a unique URLs index and I don't care about retrieving the original title from the URL, but with these function I can filter all url variations and be sure that urls are not the same :
- case sensitive
- ignore any accents
- removing tags
- remove special chars
- (optionnaly) only alpha numerics
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#