I am creating a site in which it will include("test.txt"); in an area of the body of the document...
I was wondering, is there a way to search that txt document and tell it to replace all the hard returns in the document to <br> so that it shows up that exact way in the final product? This way the person updating that information doesn't have to use tags...
Thanks all!
PHP txt Find (Question)
Moderator: General Moderators
it is still not doing what i wanted... i have the following code:
and then in the body i call
but in the .txt file where i have returns, it will not show the returns on the webpage... that is what i am wanting to do...
Code: Select all
<?
// Set the directory where the TXT files are located
$txtdir="txt/";
$news="test.txt";
$news=nl2br($news);
?>Code: Select all
<?
include($txtdir.$news);
?>The function works on strings.. not entire files.
You need to do something like this:
- Rook.
You need to do something like this:
Code: Select all
<?php
// Set the directory where the TXT files are located
$arr = file($txtdir.$news);
foreach ($arr as $k => $v) {
echo nl2br($v);
}
?>