thetooth Posted August 29, 2008 Share Posted August 29, 2008 hi i am using a light weight bbcode parser called http://www.webtech101.com/PHP/simple-bb-code and i've ran into a big prob. i writ a simple file editor so i can type in bbcode and then the parser takes care of it but the prob is i don't know how i should be calling in the text file so the parser can use it. I've tried include and fopen but both don't work because $t must equal 'the raw bbcode' so using some like $t = include('file.txt'); will ether give me an error or will call the file name and script instance rather then the text in the file. so heres my script below please help me! <?php ////////////////////////////////////////////////////////////////////////////////// //Display pharsed text//////////////////////////////////////////////////////////// //error_reporting(~E_ALL); $t = fopen("file.txt","r"); require_once('engine.php'); $bb = new BB_Code(); $res = $bb->parse($t); echo "<div style='border:1px solid #CCCCCC'>$res</div>"; ////////////////////////////////////////////////////////////////////////////////// //Now lets make a form to edit the text :)//////////////////////////////////////// if($_POST['Submit']){ $open = fopen("file.txt","w+"); $text = $_POST['update']; fwrite($open, $text); fclose($open); echo "File updated.<br />"; echo "File:<br />"; $file = file("file.txt"); foreach($file as $text) { echo $text."<br />"; } }else{ $file = file("file.txt"); echo "<form action=\"".$PHP_SELF."\" method=\"post\">"; echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">"; foreach($file as $text) { echo $text; } echo "</textarea>"; echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n </form>"; } ?> Link to comment https://forums.phpfreaks.com/topic/121818-how-to-parse-an-external-txt-file/ Share on other sites More sharing options...
MasterACE14 Posted August 29, 2008 Share Posted August 29, 2008 look into file_get_contents(); Link to comment https://forums.phpfreaks.com/topic/121818-how-to-parse-an-external-txt-file/#findComment-628513 Share on other sites More sharing options...
thetooth Posted August 29, 2008 Author Share Posted August 29, 2008 OMG dude i love you!!!!!!!!!!!!!!!!!!!!!!!!!!!! this thing has had me shit fitin for a week and now it works!!!!!!!!!!!! thank you so much Link to comment https://forums.phpfreaks.com/topic/121818-how-to-parse-an-external-txt-file/#findComment-628520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.