Page 1 of 1

preg_replace arrays "mixing it up"

Posted: Mon Mar 03, 2008 10:19 pm
by ricnut

Code: Select all

 
 
$fp = fopen("SANDLER.DOC", 'r');
$l = fread($fp, 5000);
$patterns = array("/waterboy/","/You can do it!/");
$replacement = ""; 
$description = preg_replace($patterns, $replacement, $l); 
 
//My goal is to have both techniques working together to filter the contents of SANDLER.DOC
//and echo both sections back as $description.
 
 
$patterns[0] = "/lama/";
$replacement[1] = "//";
$description = preg_replace($patterns, $replacement, $l);
 
 
echo $description;
 
 

Re: preg_replace arrays "mixing it up"

Posted: Tue Mar 04, 2008 12:22 am
by Christopher
Is there a question here?

Re: preg_replace arrays "mixing it up"

Posted: Tue Mar 04, 2008 1:27 am
by ricnut
Assuming that the sandler.doc contains the words, lama waterboy and the phrase "You can do it!" I need to use these two approaches in combination to replace these words.