Re: need to change $ char in string
| From: | Jason Wong | Date: | Sat, 29 Jun 2002 17:43:06 +0000 |
| Subject: | Re: need to change $ char in string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104505@lists.php.net to get a copy of this message | ||
On Sunday 30 June 2002 01:24, Beverly Steiner wrote:
> Thanx for your suggestion but I tried it and it didn't work. I'm not sure
> if it matters, but this running on NT.
Not sure whether NT has anything to do with it but it works for me :-)
If you can't get the following code to work then you might want to check
whether it is a known bug (http://bugs.php.net).
<?
$test_string = '1.2$General/ms1.zip';
$new_string = preg_replace("/\\$/", "%", $test_string);
echo "new_string is $new_string";
?>
But as someone has pointed out, you should be using single-quotes to prevent
unwanted/unexpected variable expansion:
$new_string = preg_replace('/\$/', '%', $test_string);
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
All great discoveries are made by mistake.
-- Young
*/