Problem replacing part of a string
| From: | Don | Date: | Wed, 29 Aug 2001 15:48:11 +0000 |
| Subject: | Problem replacing part of a string | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-65037@lists.php.net to get a copy of this message | ||
Hi,
I have a PHP routine that writes to a text file. An example output line would be:
fputs($fp, $form["notify_1"] . "\n");
Where $form["notify_1"] is an array of form variables passed to it. What I wish to do is
prior to writing to the text file, I want to search and replace all ')' with '}'
and all '(' with '{'. I did the following change to the line of code above and
wrote the following function:
fputs($fp, txt_change($form["notify_5"]) . "\n");
function txt_change($txt_string) {
$prt_string = str_replace("(", "{", $txt_string);
$prt_string = str_replace(")", "}", $txt_string);
return $prt_string;
}
My problem is that the search and replace is NOT working. According to the manual, my syntax for
"str_replace" is correct. Does anyone have an idea?
Thanks,
Don