title: arrangement of text file using PHP
body: <p>I am working on a tool to export some data from database to the text files. The code is given below:</p>
  
  <pre><code>    $query3=mysql_query("SELECT * FROM records WHERE domain_id=".$domainID." AND type='NS' ORDER BY id ASC, name ASC");
      while($result3 = mysql_fetch_array($query3))
      {
          $type=$result3['type'];
          $content=$result3['content'];
          $result = $result3['name'];
          $length = strlen(".".$domainNAME);
          $string = substr($result, 0, $length*(-1));
          fwrite($fh,$string."                    IN NS ".$content."\n");
  
      }
  </code></pre>
  
  <p>So one of the output text file is like:</p>
  
  <pre><code>                             IN NS ns1.example.net.
  
   team.example.net.                  IN NS ns1.example.net.
  
   team.example.net.                  IN NS ns2.example.net.
  
   teamex01.example.net.                  IN NS ns1.example.net.
  
   teamex01.example.net.                  IN NS ns2.example.net.
  
   dev.example.net.                   IN NS ns1.example.net.
  
   dev.example.net.                   IN NS ns2.example.net.
  </code></pre>
  
  <p>I want to output the file like :</p>
  
  <pre><code>                                    IN NS ns1.example.net.
  
   team.example.net.                  IN NS ns1.example.net.
  
   team.example.net.                  IN NS ns2.example.net.
  
   teamex01.example.net.              IN NS ns1.example.net.
  
   teamex01.example.net.              IN NS ns2.example.net.
  
   dev.example.net.                   IN NS ns1.example.net.
  
   dev.example.net.                   IN NS ns2.example.net.
  </code></pre>
  
  <p>I want to arrange it by column. IN NS record should be arrange in one column. Is there any way to arrange the file?</p>
  
  <p>Thanks!</p>