jrbilodeau Posted March 6, 2009 Share Posted March 6, 2009 Hi, I'm working on a site that i post some guitar tabs and music with cords. i upload the music a .txt files which is fine, except when i try to read in that file, the not all spaces show up correctly so now the cords don't show up over the right words. this is what i tried to display the contents of the txt file on the page $content = file("_files/music/electric/$electric"); $j = count($content); for($i=0; $i < $j; $i++){ print "<font size=2 face=\"Lucida Console\">$content[$i]</font><br>"; } i also tried this but got the same results. $file = fopen("_files/music/electric/$electric", "r") or exit("Unable to open file!"); while(!feof($file)){ echo fgets($file). "<br />"; } fclose($file); Any suggestions of how to display the contents of the txt file on the webpage with all the spaces correctly? thanks Link to comment https://forums.phpfreaks.com/topic/148224-file-not-showing-spaces-correctly/ Share on other sites More sharing options...
jackpf Posted March 6, 2009 Share Posted March 6, 2009 Try putting <pre></pre> round the file when echoing its contents. This preserves white space. Alternatively, (and the way I prefer) is to achieve the same effect with css- <span style="white-space: preserve;"></span> Hope this helps Link to comment https://forums.phpfreaks.com/topic/148224-file-not-showing-spaces-correctly/#findComment-778139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.