function txt_change($txt_string) {
$prt_string = str_replace("(", "{", $txt_string);
$prt_string = str_replace(")", "}", $txt_string);
return $prt_string;
}
even you replace with first statement, you "forget" it. Better :
function txt_change($txt_string) {
$txt_string = str_replace("(", "{", $txt_string);
$txt_string = str_replace(")", "}", $txt_string);
return $txt_string;
}
Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
99%
----- Original Message -----
From: "Don" <[EMAIL PROTECTED]>
To: "php list" <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 6:48 PM
Subject: [PHP] Problem replacing part of a string
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]