PHP Replace Spaces in URL with %20 (PRSU20)


PRSU20:   SOLD       




I want to replace all spaces in a url with %20. How do I do that with regex?

Thank You!

Solutip

No need for regex here, if you just want to replace a string with another: using  str_replace() should be more than enough:

$new = str_replace(' ', '%20', $your_string);

However, if you want more than that, and you probably do, if you're working with URLs, you should take a look at  urlencode() the functionality.


Post a Comment

Previous Next

نموذج الاتصال