title: Substring each line of the string
body: <p>inside my <code>$result</code> variable i have a 5 line string:</p>
  
  <p>0100014746510106200140001020061780000000041666670072860103508101
  0100008030950106200270002020139450000000020000006663540105338500
  0100004586400106200270002020206660000000003700000511890102603900
  0100008204530106200270002020218320000000011666670014450101008906
  0100015309660106200270002021023010000000019400001666460105319807</p>
  
  <p>how can i <code>substr()</code> each line... in order to have this result:</p>
  
  <p>010001 <br>
  010000 <br>
  010000 <br>
  010000 <br>
  010001 <br></p>
  
  <p>in only need to get the first 6 columns of each line... please help...</p>
  
  <p>PHP code:</p>
  
  <pre><code>$file = 'upload/filter.txt';
  $searchfor = $_POST['search'];
  $filename = $_POST['filename'];
  $btn = $_POST['button'];
  
  
  if($btn == 'GENERATE' ) {
  
  //prevents the browser from parsing this as HTML.
  //header('Content-Type: text/plain');
  header("Pragma: public");
  header("Expires: 0");
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  header("Content-Type: application/force-download");
  header("Content-Type: application/octet-stream");
  header("Content-Type: application/download");;
  header("Content-Disposition: attachment;filename=".$filename.".txt ");
  header("Content-Transfer-Encoding: binary ");
  
  
  // get the file contents, assuming the file to be readable (and exist)
  $contents = file_get_contents($file);
  
  // escape special characters in the query
  $pattern = preg_quote($searchfor, '/');
  
  // finalise the regular expression, matching the whole line
   $pattern = "/^.*$pattern.*\$/m";
  
  
   // search, and store all matching occurences in $matches
   if(preg_match_all($pattern, $contents, $matches)){
   $result = implode("\n", $matches[0]);
   echo $result;
  
  
    }
  
  else{
   echo "No matches found";
   }
  
  }
  </code></pre>