|
Posted by Rik on 07/05/06 14:11
Dan Pearce wrote:
> Processing some text from an external text file into a web page. If I
> use this:
>
> <?
> $s = file_get_contents('text.txt');
> $search = array("@\r\n@si");
>
> $replace = array('</br>');
Here's you problem already:
It should be '<br />' in XHTML, '<br>' in HTML.
> echo preg_replace($search, $replace, $s);
>>
>
> Explorer shows the text as it appears in the file;
Apparantly MSIE forgives your mistake and chooses to interpret '</br>' as
'<br>'. FF correctly interprets it as a bogus tag and tries to ignore it.
Why not use the function nl2br() though?
Or, if you have a text-file with preformatted text, use the HTML <pre> tag.
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|