I have a string which eventually has characters I don't want and all of these unallowed characters should be replaced by a pipe |
For example:
", "
" ,"
"| "
" |"
"\""
"\\"
These characters should be replaced by a pipe.
What ist the quickest and most effective way to do that? String fuction or RegExps?
Character replacement
Moderator: General Moderators
-
visionmaster
- Forum Contributor
- Posts: 139
- Joined: Wed Jul 14, 2004 4:06 am
Probably something like:
Code: Select all
$replace = array(', ', ' ,', '| ', ' |', '\''); //array of stuff to replace
$string = str_replace($replace, '|', $string);