How to export long number as string in csv file using php

1.8k Views Asked by At

When I am trying to export all fields are okay except NID field. This numbers length is 17+ so, how can I show all the numbers in this field(nid)?? I have

Here is the example of excel

<?php

$filename = "hello.csv";
$query = "SELECT * FROM test_users";
$result_users = $this->conn->prepare($query);
$result_users->execute();
// Create array
$list = array ();

// Append results to array
array_push($list, array("## START OF May TABLE ##"));
while ($row = $result_users->fetch(PDO::FETCH_ASSOC)) {
    array_push($list, array_values($row));
}
array_push($list, array("## END OF May TABLE ##"));

// Output array into CSV file
$fp = fopen('php://output', 'w');
fputcsv($fp, ['Serial NO','English Name','Bangla Name','address','bn_address','user_no','nid','previous_cm','meter_no','type_of_user']);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
foreach ($list as $ferow) {
    fputcsv($fp, $ferow);
}
0

There are 0 best solutions below