在 file_get_contents php 中格式化 txt

Formatting txt in file_get_contents php

我有这个代码来显示 txt 文件:

<textarea rows="11" cols="190">
<?php
$file = file_get_contents('./test.txt', FILE_USE_INCLUDE_PATH);
echo $file;
?>
</textarea>

txt 文件如下所示:

在一个干净的 html 文件中,它看起来像这样:

但是当我使用 portoadmin 模板将它粘贴到 laravel 时,txt 格式被破坏了,它看起来像这样:

这有什么问题吗?

提前致谢

将您的网络字体更改为等宽字体,如 this。例如,如果您在内部渲染 txt 文件:

<div id="container">
</div>

然后确保 #container 元素使用 monospace-type 字体。例如:

#container {
    font-family: "Roboto Mono", monospace;
}