Help with preg_replace

From: Date: Wed, 07 Nov 2007 23:42:26 +0000
Subject: Help with preg_replace
Groups: php.general 
Request: Send a blank email to php-general+get-264198@lists.php.net to get a copy of this message
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@resmaster.com Tel: (+612) 4751-9633 Fax: (+612) 4751-9644 Web: www.resmaster.com ================================================= Exodus Systems - Smarter Systems, Better Business =================================================

« previous php.general (#264198) next »