Jump to content

how do i remove a certain word/phrase from a file ?


yami007

Recommended Posts

<?php

$filename = 'emails.txt';

if(isset($_GET['r'])) {
$file = file_get_contents($filename);
$remove = strip_tags($_GET['r']);
$content = str_replace($remove,'',$file);
file_put_contents($filename,$content);
}
echo nl2br(file_get_contents($filename));
?>
<form action="" method="get">
<input type="text" name="r" value="" />
<input type="submit" name="submit" value=" Remove " />
</form>

 

UN-Tested.

Another method that was posted by a user here is

 

function wordsExist(&$string, $words) {
    foreach($words as &$word) {
        if(stripos($string, $word) !== false) {
            return true;
        }
    }
    return false;
}

$string = $VARIABLE;
if (wordsExist($string, array('WORD1','WORD2'))) {
    die("<font color='red'><font size='15'><strong><center>Your post contains a blocked word!");
}

I don't know the name of who posted it, so sorry  :shrug:.

 

EDIT:

>file

My bad.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.