Mình đã xuất ra file .csv thành công, nhưng không hiển thị tiếng việt được (đọc bằng microsoft excel). Mong các bạn giúp đỡ!
function exportToCSV(){
global $database;
// lấy dữ liệu từ DB
$us = new xl_user;
$arr = $us->list_user();
// Lấy dữ liệu gắn vào xâu $info
header('Content-Type: text/html; charset=utf-8');
$info = "Username, Password, Họ tên\n";
foreach($arr as $r)
{
$info .= $r['Username'].",".$r['Password'].",".$r['Hoten']."\n";
}
// chọn kiểu file
header('Content-type:text/csv;');
// chọn tên file
header('Content-disposition:attachment;filename= thiet ke website tai tphcm.csv ');
// Xuất dữ liệu
echo $info;
exit();
}
exportToCSV();