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 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 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> 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
Archived
This topic is now archived and is closed to further replies.