Search code examples
phpreplacestring-literalssanitization

Removing two blacklisted characters from a string


Given the address: 12345 West Palm Rd., #7B Daytona, FL

I am trying to remove the '.' character from 'Rd.' and the '#' character from '#7B'. However, I would like for these characters to be removed no matter what string is given.

Is there an easy way to do this?

I am familiar with strstr(), but it seems like a complicated way to do what I am trying to do.


Solution

  • $string = str_replace (array(".", "#"), "", $string);