Help with preg_replace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi 

I am in the process of porting a Perl application to PHP and I have hit a snag
with trying to substitute test within a file. I have looked at the PHP manual
and believe I should be using preg_replace but I have tried the examples and am
not getting the result I would expect. I would appreciate any help in getting
this to work.

In Perl I have the following

$html = `cat htmlfile`;
$html  =~ s/%ResID/$bookid/g;

which replaces each instance of %ResID with the contents of the variable $bookid

In PHP I have tried

$html = `cat htmlfile`;
$html = preg_replace('%ResID',$bookid,$html);

When I run this I find $html is empty rather than containing the file with the
%ResID replaced with the contents of $bookid.

I would appreciate any help with my understanding of preg_replace.



Regards,
Richard Luckhurst                      
Product Development
Exodus Systems - Sydney, Australia.
rluckhurst@xxxxxxxxxxxxx
Tel: (+612) 4751-9633
Fax: (+612) 4751-9644
Web: www.resmaster.com 
=================================================
Exodus Systems - Smarter Systems, Better Business
=================================================

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux