Hey,
So I have a function to generate a slug URL, all the generated URLs must match a .htaccess rewriterule allowing only alpha-numerics, hyphens and underscores.
My question is; how do I remove ALL characters other than the allowed characters.
For reference, my URL rewrite is ([0-9a-zA-Z_-]+)
-Sam
samarudge
16
Posting Whiz
Recommended Answers
Jump to Postassuming
[0-9a-zA-Z_-]
represents the set of allowed characters, and that $url contains the hyperlink you want to "clean", then try:$url = preg_replace('#[^0-9a-zA-Z_-]#','',$url);
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.