title: How to save value from a selected checkbox to a file using php?
body: <p>My text file is as follow:</p>
  
  <blockquote>
    <p>12345 234 455<br>
    23 67 9666 13 56<br>
    1234 777 900</p>
  </blockquote>
  
  <p>whenever I'm checking the preferred check-boxes only the first value of each line appear other value does not appear ,I mean like for the first line only 12345 is appearing and 234 455 don't appear ;
  Does any one help me?
  I need whenever I'm selecting any check boxes the complete line contain should be selected or appearing as well</p>
  
  <p>process.php
      
  
  <pre><code>require 'connect.inc.php';
  
  if(isset($_POST['check']) &amp;&amp; ! empty($_POST['check']))  
  {
      $check=$_POST['check'];
      $numberOfCheck=count($check);
  
      echo ("You have checked $numberOfCheck checkboxes : ");
  
      for ($i=0; $i&lt;$numberOfCheck; $i++)  
      {
          echo '&lt;br&gt;';
          echo ($check[$i]. " ");
  
          $VarCheck=$check[$i];
          $name=time();
          $myFile=fopen($name,"a");
          $txt=$VarCheck;
  
          fwrite($myFile,$txt);
          fclose($myFile);    
      }
  }
  else
  {
      echo "Zero check selected";
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>This is my dynamic table generating according to the number of line of my file text</p>
  
  <pre><code>&lt;?php
  
  echo '&lt;form method="POST" action="process.php"&gt;';
  
  $file = fopen("text.txt","r");
  
  echo '&lt;table border="1"&gt;';
  
  while(! feof($file))
  
    {
  
    $data= fgets($file);
  
  echo '&lt;tr&gt;
  
  &lt;td&gt;&lt;input type="checkbox" name="check[]" value='.$data.'&lt;/td&gt;
  
  &lt;td&gt;'.$data.'&lt;/td&gt;&lt;/tr&gt;';
  
  
    }
  fclose($file);
  
  echo '&lt;input type="submit" value="send"&gt;';
  
  echo '&lt;/form&gt;';
  
  ?&gt;
  </code></pre>