Perl find and replace in PHP
| From: | rluckhurst at resmaster dot com | Date: | Mon, 26 Mar 2007 11:17:37 +0000 |
| Subject: | Perl find and replace in PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-251358@lists.php.net to get a copy of this message | ||
Hi All
I am porting some perl to PHP and have struck a small snag. The perl
script has quite a few substitutions that take place so data can be fed
into a html page.
The script uses the following perl syntax
$html =
cat search_results.html;
$html =~ s/%Accom/$accom/g;
As I understand perl that should cat the html file into a variable called
$html. It should then perform a global substitution replacing %Accom with
the contents of the variable $accom.
Is such a thing possible in PHP? If so how? I have been doing google
searches for a while and can find no simple explanation of how to perform
this in PHP. The nearest I can find is using a preg_replace but I am
unsure if that will do what I need.
Does anyone know if this can be done?
Regards
Richard Luckhurst