<?php function syn ($in) { $symbols = "!?.,\"';:<>()[]*-=+"; for ($x = 0; $x< strlen ($symbols); $x++) { $in = str_replace ($symbols{$x}, ' '.$symbols{$x}, $in); } $words = fopen ('words.txt', 'r'); while (!feof ($words)) { $row = trim (fgets ($words)); list ($word, $syn) = explode ("|", $row); if ((strpos ($in, " ".$word." ") === false) && (strpos (ucfirst ($in), " ".ucfirst ($word)." ") === false)) continue; $in = str_replace (" ".$word." ", "|".$syn."|", $in); $in = str_replace (" ".ucfirst ($word)." ", "|".ucfirst ($syn)."|", $in); } fclose ($words); $in = str_replace ("|", " ", $in); for ($x = 0; $x< strlen ($symbols); $x++) { $in = str_replace (' '.$symbols{$x}, $symbols{$x}, $in); } return $in; } $d = opendir ('in'); while (($file = readdir ($d)) !== false) { if ($file {0} == '.') continue; file_put_contents ('out/'.$file, syn (file_get_contents ('in/'.$file))); echo $file."\r\n"; } ?>