如何在php中为select group查询中的每个组插入一个空行

I am using PHP to export a text file from a query. The selection result is as follows

Account   student_no
001        stu_001
           stu_001

001        stu_002
           stu_002

Which I selected by (select * from payment group by account,student_no asc, so my question is I need to insert a blank line between each group (i.e. 001 stu_001, 001 stu_002) for the export text file. So how can I do that in PHP.

Assuming you build up your output in a string, just add between double quotes:

$output_string = 'This line is followed by a new line'. "
";
$output_string .= 'And I add another line'. "
";

First ORDER the results by account and then

$previousAccount="";
foreach($records as $record)
{
   $account=$record["account"];
   if($account!=$previousAccount)
  {
   $output.=PHP_EOL;  // or echo or fwrite etc
  }
  $previousAccount=$account;
...
...
...
...
}

Use this tab to define where and how many blank lines you want PhpStorm to retain and insert in your code after reformatting. For each type of location, specify the number of blank lines to be inserted. The results are displayed in the Preview pane....Code Style. PHP

 $output = sprintf( "%20s %20s 
", "Account","student_no" );    // Print Account   student_no
 foreach($record as $row){
      $output .= sprintf( "%20s %20s",$row['account'], $row['student_no'] ) . "
";
 }

http://pastebin.com/qrBZzywh