liveandlearn Posted February 5, 2009 Share Posted February 5, 2009 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 More sharing options...
N1CK3RS0N Posted February 5, 2009 Share Posted February 5, 2009 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. Link to comment https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/#findComment-755004 Share on other sites More sharing options...
liveandlearn Posted February 5, 2009 Author Share Posted February 5, 2009 i still need the output to be edited, trying the 4 space thing. and it works but i want a friend to be able to only type txt file i could also keep the nl2br but then i need to know how to mod the http:// and the @ to weblink and mail Link to comment https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/#findComment-755010 Share on other sites More sharing options...
liveandlearn Posted February 5, 2009 Author Share Posted February 5, 2009 I know the replacement thiggy is possible if only there was a easier way for the breaks to come true Link to comment https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/#findComment-755075 Share on other sites More sharing options...
TheLoveableMonty Posted February 5, 2009 Share Posted February 5, 2009 $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. Link to comment https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/#findComment-755076 Share on other sites More sharing options...
liveandlearn Posted February 5, 2009 Author Share Posted February 5, 2009 $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. Link to comment https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/#findComment-755078 Share on other sites More sharing options...
liveandlearn Posted February 5, 2009 Author Share Posted February 5, 2009 $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 Link to comment https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/#findComment-755104 Share on other sites More sharing options...
liveandlearn Posted February 5, 2009 Author Share Posted February 5, 2009 Does no one have the answer. i can use the 4 spaces thinggy, but still need to change the http and the @ into web and mail adress and it seems that this forum even does that Link to comment https://forums.phpfreaks.com/topic/143887-going-crazy-with-this-break-problem/#findComment-755414 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.