www.cahyonegoro.com www.cahyonegoro.com - 1 month ago 15
HTML Question

formatting txt in file_get_contents php

so i have this code to show txt file :

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


the txt file look like this:
enter image description here

in one clean html file, it looked like this:
the format is exactly like the txt file

but when i paste it in laravel with portoadmin template, the txt format is broken and it looked like this:
the format is broken

what is wrong whit that????

thanks before

Answer

Change your web-font into monospace-type font, like this. For example, if you render your "txt" file inside:

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

Then make sure that #container file is using Monospace font:

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