Hi can anyone help with a string searh query

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
spudmclard
Forum Newbie
Posts: 16
Joined: Thu Oct 27, 2005 3:06 am

Hi can anyone help with a string searh query

Post by spudmclard »

Hi

Basically what im after is a way to search a flat text file for a requested string and be able to remove the said string if its found.

IE.
Text file contents
~~~~~~~~~~~
apple
banana
cherry

If the user types banana into the form and submits it then the text file is appended to have banana removed.

Hope someone can help..
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Post by someberry »

Code: Select all

<?PHP
$f = Array('Apple', 'Banana', 'foo', 'bar');
$str = 'I had an apple for breakfast, a banana for lunch, followed by a foobar for dinner.';

$str = str_replace($f, '', $str);
?>
Post Reply