Code: Select all
<?php
$words_array = preg_replace("#\r\n?|\n#","",file('words.dat')); // read the file into an array and remove new line breaks (should cover all OS)
$word_stars = preg_replace( '/./','*',$words_array ); // replace every letter with a *
$words_array = preg_replace( '/(.+)/','#\1#i',$words_array ); // put # delim around each word
$message = preg_replace($words_array,$word_stars,$message);
?>