scoobydoo9749 Posted July 15, 2007 Share Posted July 15, 2007 I need to create a string from a .txt file so it can be displayed in the <textarea> of an html form. This is what I had: $body = fopen("example.txt","r+"); $text = ""; while (!feof($body)) { $text += fgetc($body); } echo $text; All it prints out is 0. Also, if there's a better way to get the text from the txt file please let me know. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 15, 2007 Share Posted July 15, 2007 http://uk.php.net/file_get_contents Quote Link to comment Share on other sites More sharing options...
Barand Posted July 15, 2007 Share Posted July 15, 2007 The text concatenation operator is ".", not "+" $text .= fgetc($body); However, as redarrow indicated, file_get_contents is far simpler. Quote Link to comment 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.