Read line and change the line that not consist of certain words and not end with dot
<p>I wanna read some text files in a folder line by line. for example of 1 txt :</p>

<pre><code>Fast and Effective Text Mining Using Linear-time Document Clustering
Bjornar Larsen WORD2 Chinatsu Aone
SRA International AK, Inc.
4300 Fair Lakes Cow-l Fairfax, VA 22033

{bjornar-larsen, WORD1
</code></pre>

<p>I wanna remove line that does not contain of words = <code>word</code>, <code>word2</code>, <code>word3</code>, and does not end with dot <code>.</code></p>

<p>so. from the example, the result will be :</p>

<pre><code>Bjornar Larsen WORD2 Chinatsu Aone
SRA International, Inc.
{bjornar-larsen, WORD1
</code></pre>

<p>I am confused, hw to remove the line? it that possible? or can we replace them with a space?</p>

<p>here's the code :</p>

<pre><code>$url = glob($savePath.'*.txt');
foreach ($url as $file =&gt; $files) {
    $handle = fopen($files, "r") or die ('can not open file');
    $ori_content= file_get_contents($files);
    foreach(preg_split("/((\r?\n)|(\r\n?))/", $ori_content) as $buffer){
        $pos1 = stripos($buffer, $word1);
        $pos2 = stripos($buffer, $word2);
        $pos3 = stripos($buffer, $word3);
        $last = $str[strlen($buffer)-1];//read the las character
        if (true !== $pos1 OR true !== $pos2 OR true !==$pos3 &amp;&amp; $last != '.'){
        //how to remove
        }
    }
}
</code></pre>

<p>please help me, thank you so much :)</p>
