CodeClerks

Remove special characters and symbols from Api data(For affiliates)



Enter a reason for deleting this comment

Remove special characters and symbols from Api data(For affiliates)

Hi I noticed with the Api, That it receives the titles and descriptions with symbols / special characters if the user put them in there service info. So I made a little function for the affiliates to remove the symbols (If wanted)

Example of description before function:
<=====++++++++++Buy now for 1$++++++++++=====> This is an awesome service

Example after ran in function:
Buy now for 1$ This is an awesome service



Just add below anywhere in you're script


fucntion ReplaceSymbols($string) {
  $Text_Tidy = preg_replace('/[^a-zA-Z0-9_ $%\[\]\.\(\)%&-]/s', '', $string);
  echo $Text_Tidy;
}
 


Then use something like this to call it
ReplaceSymbols($data->description);


I hope some of you find it useful Remove special characters and symbols from Api data(For affiliates)
If you own an affiliate store you most likely noticed a lot of symbols in some service descriptions this helped me alot. If you have a method to solve problems like this please share "sharing is caring"

Comments

Please login or sign up to leave a comment

Join
robertman11

Very useful, thanks for the share.



Enter a reason for deleting this comment