Al wrote: > Delimiters needed. Can use about anything not already in your pattern. > "/" is very commonly used; but I like "#" or "%" generally; but, you > can't use "%" because your pattern has it. > > $html = preg_replace("#%ResID#",$bookid,$html); wont a str_replace() do just fine in this case? // and we can do backticks too ;-) $html = str_replace("%ResID", $bookid, `cat htmlfile`); > > > Richard Luckhurst wrote: >> 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