V
V
Vlad2018-04-03 17:52:45
PHP
Vlad, 2018-04-03 17:52:45

How to make data readable?

In general, I take a txt file from a certain site and display it on my site via file_get_content + echo ().
Everything is successfully displayed, but it has an extremely unpleasant appearance - the font is standard, all the lines have strayed into one whole text. How to make the text on my site (second screenshot) look like on the other one (first screenshot). Using HTML won't help since my site will be used for the same scraping by other users.
5ac3953303089348200798.png5ac3953bc1aa0705502123.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Sisin, 2018-04-04
@thoozu

giving header Content-type: text/plain doesn't help?

Q
Quark_rgb, 2018-04-03
@Quark_rgb

Might fit like that

$text = file_get_contents( "././text.txt"); // 125.141.200.54:80 182.110.222.10:35419 187.44.14.19:8050

$replace = preg_replace('/(\s)/', "$1\n", $text);
echo $replace;

125.141.200.54:80
182.110.222.10:35419
187.44.14.19:8050

P
Paul Denisevich, 2018-04-03
@deniamnet

echo nl2br($text);
This will add a newline on the page after each address (assuming there is a newline in the source text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question