Jitesh Sojitra
Jitesh Sojitra

Reputation: 4043

Reading text file truncates line output in PHP

Reading text file truncates line output in PHP:

Text-file:

NEXT_GEN_TO="Project Bribara<[email protected]>"

Code:

$lines = file('Text-file');
foreach ($lines as $line) {
   echo "$line</br>";
}

Expected:

NEXT_GEN_TO="Project Bribara<[email protected]>"

Actual:

NEXT_GEN_TO="Project Bribara"

How can I print expected result after reading the lines from file?

Upvotes: 0

Views: 33

Answers (2)

tanaydin
tanaydin

Reputation: 5316

Try to give output like this...

echo htmlentities($line) . "</br>";

Upvotes: 1

Digits
Digits

Reputation: 2684

The <[email protected]> is treated as an html tag by your browser. If you check out the outputted html source code for the page using "View Source" in your browser, it's all going to be there.

Use one of the php functions to turn html into non-html text such as htmlentities() on the text before output.

http://php.net/manual/en/function.htmlentities.php

Upvotes: 2

Related Questions