John Nichel wrote:
Paul Nowosielski wrote:
I wrote a function to do this for our product descriptions when sending
them in a XML doc to certain vendors. It's old, crude, but you're
welcome to it.
<snip function that uses regular expressions for simple string replacements>
Using regular expressions for that is a very bad idea. You're using
regular expressions for simple string matches, which is going to be much
slower than just using the simple string replace functions. It even
warns you against doing what you're doing in the manual.
Here's a function that demonstrates replacing several characters with
something else
function replaceChars($string)
{
$find_array = array("a", "b", "c");
$replace_array = array("apple", "banana", "carambola");
return str_replace($find_array, $replace_array, $string);
}
You can, of course, throw other string processing functions in there.
Regards, Adam Zey.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php