davemcc Posted October 11, 2007 Share Posted October 11, 2007 Hello can anyone help?! I am using the following php within a div <?php $lines = file("news.txt"); echo '<pre>'; foreach($lines as $line) echo str_replace("<", "<", $line)."\n"; echo '</pre>'; ?> Is their any way to constrain the php displayed txt to within the div width see http://mickleovercommunitycentre.co.uk/Oakwood/phptrial2.php latest news box for my prob. any help would be great! Dave Quote Link to comment https://forums.phpfreaks.com/topic/72769-php-displayed-txt-file-word-wrapping-in-a-div/ Share on other sites More sharing options...
agazad Posted October 11, 2007 Share Posted October 11, 2007 It's nothing to do with the php code, it's to do with your DIV. Remove the < pre > tags. Gary Quote Link to comment https://forums.phpfreaks.com/topic/72769-php-displayed-txt-file-word-wrapping-in-a-div/#findComment-367013 Share on other sites More sharing options...
agazad Posted October 11, 2007 Share Posted October 11, 2007 <div id="Layer2" style="width:292px; height:226px;" class="newsposition"> <p>Latest News </p> <p> <?php //$lines = file("http://mickleovercommunitycentre.co.uk/Oakwood/news.txt"); $myFile = "http://mickleovercommunitycentre.co.uk/Oakwood/news.txt"; $fh = fopen($myFile, 'r'); $theData = fgets($fh); fclose($fh); echo $theData; ?> </p> </div> Quote Link to comment https://forums.phpfreaks.com/topic/72769-php-displayed-txt-file-word-wrapping-in-a-div/#findComment-367027 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.