我无法在html表格上显示的csv文本上显示utf chars,即使使用php标题并在html头上设置charset字符未正确显示,我是否必须在csv上设置内容??
<?php
header('Content-Type: text/html; charset=UTF-8');
$row = 1;
$table = array();
if (($handle = fopen("csv/myfile.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
array_push($table, explode(';', $data[0] ) );
}
fclose($handle);
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<link href="./libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="./libs/bootstrap/css/jumbotron-narrow.css" rel="stylesheet">
<link href="./libs/css/styles.css" rel="stylesheet">
</head>
<body>
<div>
<table class="table-bordered">
<tr>
<?php
for($i = 0; $i < count($table[0]); $i++){
echo "<th>".$table[0][$i]."</th>";
}
?>
</tr>
<?php
for($i = 1; $i < count($table); $i++){
echo "<tr>";
for($j = 0; $j < count($table[$j]); $j++){
echo "<td>".htmlentities($table[$i][$j])."</td>";
}
echo "</tr>";
}
?>
</table>
</div>
<script src="./libs/jquery-3.2.1.min.js"></script>
<script src="./libs/bootstrap/js/bootstrap.min.js"></script>
<script src="./libs/script.js"></script>
</body>
</html>