Reputation: 66
How can I remove two character? Here's my code:
str_replace('\'| ', '',"remove ' and spaces");
I'm trying to use the | but it's not working
Upvotes: 1
Views: 898
Reputation: 626893
Looking at \'|
, it seems you want to remove either '
or a space. str_replace
(that does not allow regex as its needle argument) accepts an array of search strings as the first argument:
search
The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
So, use
$s = str_replace(array("'",' '), "", "remove ' and spaces");
// => removeandspaces
See demo
Upvotes: 2