I'm trying to make a simple "Paypal" link generator for an insurance ageny. Here is an example input field.
<? echo "$ItemName"; ?>
My question is, paypal is very sensitive, is there a php code that can be put within the input code to replace every "Space" with a "+".
For example instead of: Car Insurance, but Car+Insurance Paypal reads the + as a space.
Thanks for you help guys.
LD
$ItemName = str_replace(" ", "+", $ItemName);
Thanks alot, it worked!
<? $ItemName = str_replace(" ", "+", $ItemName); echo "$ItemName"; ?>
May also want to do it another time for & nbsp; characters. Plus, you don't need the quotes around the variable when echoing
Within this code, am i able to do more than 1 substitute?
For example: " ", "+": and "&","AND", and so forth, can I have it check for more than one thing?
Have you checked out urlencode()?
It would be quite a bit faster to use that then to do a whole bunch of str_replaces.
I wanted to do 1 or 2 more within the code, it would be easier for me that way. Thanks.
Just repeat for what you need before echoing
<? $ItemName = str_replace(" ","+",$ItemName); $ItemName = str_replace("&","AND",$ItemName); $ItemName = str_replace("THIS","THAT",$ItemName); echo $ItemName; ?>
Thats what I thought, i just wanted to make sure. Thanks alot!
Or put search and replace strings into arrays and pass those to single call to str_replace.