Page 1 of 1

convert str to %20 and the like in JS, then PHP convert back

Posted: Mon Oct 27, 2014 11:49 pm
by Jason_C
I have strings's that are causing problems when being sent to a PHP script via JavaScript. (not all of it is getting sent)

i.e.

This is someone's line of text & it's rather long.

I wish to convert the whole string to some other format say like the spaces to %20 and and the & to & I think, and so on...

Then once the PHP script $_GET's the string it converts it back to the original.

Re: convert str to %20 and the like in JS, then PHP convert

Posted: Tue Oct 28, 2014 7:01 pm
by freshnet
you may want to look into htmlentities() http://php.net/manual/en/function.htmlentities.php. You could use that and then convert it back if needed in php using html_entity_decode().