Skip to content
Advertisement

How to remove space from image name and replace with % in PHP?

I want to remove the space between image name and replace it with % . How can I achieve that?

Image path = ‘http://combined/nature image GREY_120_240_Glossy_OBL Premium.jpg’.

I want it to be = ‘http://combined/nature%20image%20GREY_120_240_Glossy_OBL%20Premium.jpg’

Code I have tried

JavaScript

Advertisement

Answer

You need to use rawurlencode and do it after pulling the name, presuming you want it on the naming.

JavaScript

https://3v4l.org/CptPc

I would replace any whitespace with underscores.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement