title: Edit specific record from a line in text file and PHP
body: <p>I'm trying to make a simple news hit counter with PHP and text file. i wrote a simple code to check and read the file:</p>
  
  <p><strong>Text File:</strong></p>
  
  <pre><code>//Data in Source File
  //Info: News-ID|Hits|Date
  1|32|2013-9-25
  2|241|2013-9-26
  3|57|2013-9-27
  </code></pre>
  
  <p><strong>PHP File:</strong></p>
  
  <pre><code>//Get Source
  $Source = ENGINE_DIR . '/data/top.txt';
  $Read = file($Source);
  
  //Add New Record
  foreach($Read as $News){
    //Match News ID
    if($News[0] == "2"){
      //Add New Record and Update the Text File
    }
  }
  </code></pre>
  
  <p>Problem is i can't change the news hits! For example, i need change hits from second line from <strong>241</strong> to <strong>242</strong> and write it again in to the txt file.</p>
  
  <p>I searched in this site and Google and tried some ways but i couldn't fix that.</p>