Jump to content

GOING CRAZY WITH THIS BREAK problem


liveandlearn

Recommended Posts

I have a external txt file.

I want to achieve the following:

I open up a txt file

 

$txt = fopen("ftp/announcements.txt", "r");

$txtdata = fread($txt, filesize("ftp/announcements.txt"));

fclose($txt);

echo nl2br("

$txtdata;

");

I did this cause otherwise i typed breaks don;t work u get everything in one line.

 

Been googleling for over 8 hours now getting nuts to try and get his done

i need to remove the nl2br but when i do the breaks need to stay cause my txt file has breaks

also this needs to happen:

 

http:// converts to a hyperlink

[email protected] needs to be converted to mail link

Also i want certain other character combination to be changed into bold

 

basicly i have this txt

 

Hi i am Tester

I have a break problem

http://www.google.com

 

i get this now :

Hi i am Tester I have a break problem http://www.google.com

 

I want this:

Hi i am Tester

I have a problem

http://www.google.com

 

(this page seems to change the mail and webadres already so try and understand my prob. I don;t want www to change only when it starts with HTTP:// and a mail adres when a set of characters has a @)

 

Hopefully someone knows how to fix it. cannot find the answer on the net, prolly cause i use wrong search questions

Link to comment
https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/
Share on other sites

Could just use a html file and use a <br />

 

but try 4 spaces in the .txt file. It might break it down 1 line.

 

IDK how but it does that when I include the .txt file for the GNU license in a div. It auto breaks. I notice it breaks after the 4 spaces.

  $txt = fopen("ftp/announcements.txt", "r");
  $txtdata = fread($txt, filesize("ftp/announcements.txt"));

\\ Change normal page breaks to HTML page breaks...
  $txtdata=eregi_replace("\n'","<br>'",$txtdata);

  fclose($txt);

    echo nl2br("
        $txtdata;
    ");

 

That deals with your first issue of the page breaks not appearing in HTML.

 

As for the links and bold tags, you'll have to stick to basic HTML within the file for that one. It is possible but an extremely unnecessary amount of work.

  $txt = fopen("ftp/announcements.txt", "r");
  $txtdata = fread($txt, filesize("ftp/announcements.txt"));

\\ Change normal page breaks to HTML page breaks...
  $txtdata=eregi_replace("\n'","<br>'",$txtdata);

  fclose($txt);

    echo nl2br("
        $txtdata;
    ");

 

That deals with your first issue of the page breaks not appearing in HTML.

 

As for the links and bold tags, you'll have to stick to basic HTML within the file for that one. It is possible but an extremely unnecessary amount of work.

 

so basicly \n is what a normal "enter" break in a txt file is ? or thats what u asked to change with the script. Very cool ty very much, gonna try it now. The other thing the bold is not neccesairy, is it possible to adres a certain word in css u think then its solved aswell. Furthermore i know the adres change script excist but i cannot get em figured out. I started of in visual basic and having a lil of a hard time on the php syntax not so good in remembering it yet.

  $txt = fopen("ftp/announcements.txt", "r");
  $txtdata = fread($txt, filesize("ftp/announcements.txt"));

\\ Change normal page breaks to HTML page breaks...
  $txtdata=eregi_replace("\n'","<br>'",$txtdata);

  fclose($txt);

    echo nl2br("
        $txtdata;
    ");

 

That deals with your first issue of the page breaks not appearing in HTML.

 

As for the links and bold tags, you'll have to stick to basic HTML within the file for that one. It is possible but an extremely unnecessary amount of work.

 

Werkt dus niet de nl2br zorgt er al voor dat de breaks het doen alleen kan ik dan geen hyperlinks maken. Dat moet ik dan binnen nl2br kunnen kunnen doen.

 

gebruik ik je code zonder de nl2br heb ik weer een rommel van tekst de breaks worden niet toegepast

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.