The script is supposed to search for a given word with in a text file and remove the given word, i.e. I want to use it to remove swear words from the text file which contains comments. Each comment in the text file is separated by a line.
(Here is my script, it does not seem to be working when I run it, other PHP scripts are fine)
<?php
$strText = file_get_contents( 'messages\message.txt' );
$strFind = '****';
$blMatch = false;
if( preg_match( "/$strFind/", $strText ) ) {
<blockquote>$blMatch = true;
$strText = str_replace( $strFind, '', $strText );</blockquote>}
?>
If you know of any other simple and better php scripts then please let me know, I would also ideally like to be able to remove the whole line with the bad word in!
Edited by Roger, 13 November 2011 - 09:01 AM.
added code tags


Sign In
Create Account

Back to top









