我正在尝试从mysqli数据库中创建一个.txt文档,并且像这样成功:
header('Content-disposition: attachment; filename='.$lang.'.txt');
header('Content-type: text/plain; charset=utf-8');
$jsonData = [];
$result = mysqli_query($con, "SELECT * FROM ReloadedSnippets WHERE app = $app AND type=0 ORDER BY id");
while ($row = mysqli_fetch_assoc($result)) {
$snippetId = $row['id'];
$result1 = mysqli_query($con,"SELECT * FROM ReloadedTranslations WHERE fk_snipId=$snippetId AND lang='$lang' AND app=$app");
$row1 = mysqli_fetch_assoc($result1);
$string1 = $row1["translation"];
//$string1 = mysqli_real_escape_string($con,$string1);
$jsonData[$row['snippet']] = $string1;
}
$jsonString = json_encode($jsonData, JSON_UNESCAPED_UNICODE);
echo $jsonString;
现在,我的问题是所有内容都以大行打印在txt文档中!我想使用JSON_PRETTY_PRINT,但是当我还需要使用JSON_UNESCAPED_UNICODE时该怎么做?
希望获得帮助并提前致谢:-)