preg_replace arrays "mixing it up"

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ricnut
Forum Newbie
Posts: 10
Joined: Tue Nov 21, 2006 12:44 am

preg_replace arrays "mixing it up"

Post 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;
 
 
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: preg_replace arrays "mixing it up"

Post by Christopher »

Is there a question here?
(#10850)
ricnut
Forum Newbie
Posts: 10
Joined: Tue Nov 21, 2006 12:44 am

Re: preg_replace arrays "mixing it up"

Post 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.
Post Reply