php - All records are displaying on a single row when exporting array to a csv file -


i pulling data api exporting excel file.

here's code:

// api code request here $jsondecode = json_decode($content); // echo '<pre>'; // var_dump($jsondecode);  foreach( $jsondecode $value ) {     //if null, create blank field     if ( ( !isset( $value ) ) || ( $value == "" ) ){         $value = "\t";     }     //else, assign field value our data     else {         $value = str_replace( '"' , '""' , $value );         $value = '"' . $value . '"' . "\t";     }     //add field value our row     $line .= $value; } //trim whitespace each row $data .= trim( $line ) . "\n";  //remove carriage returns data $data = str_replace( "\r" , "" , $data );  $file_name = 'excel_data'; //create file , send browser user download header("content-type: application/vnd.ms-excel"); header( "content-disposition: filename=".$file_name.".xls"); print "$header\n$data"; exit; 

as shown above, after pulling data api, pass through phpexcel library export excel file data exported displays in on single row shown below:

here screen shot of excel file getting after running script

how can have each of record of data in excel file display on new line/row?


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -