Gatsu Posted October 29, 2007 Share Posted October 29, 2007 hi, I want to print the content of a text file to my website.on the index.php I have:<td>Player Record: <?php print $record ?></td>and in config.php$record = print_r(file('E:\TheForgottenServer 0.2.6\playersRecord.txt')) ; //Player Recordsee my result at http://90.230.82.9/I want the "254" that the file contains to be printed and not the "Array ( [0] => 254 )" that comes up but on even a totally different spot on the site.Does anybody have a solution for this? Link to comment Share on other sites More sharing options...
zppblood Posted October 29, 2007 Share Posted October 29, 2007 From php.net"file — Reads entire file into an array"If you are going to have more than one record, you might want to use a database. With arrays to get information from the array, you need to have ['key'], replacing key with either a number or whatever you called it. In this case, you will replace key with 0, as you will see with the result Array([0]=>254). Link to comment Share on other sites More sharing options...
justsomeguy Posted October 29, 2007 Share Posted October 29, 2007 Don't use print_r, it's for debugging. Use implode.http://www.php.net/manual/en/function.implode.php Link to comment Share on other sites More sharing options...
Synook Posted October 30, 2007 Share Posted October 30, 2007 You could also just use file_get_contents(), which reads the file into one big string (but with only one value that won't matter). Also, you don't need to "print" or "echo" values into a variable, just assign. $record = file_get_contents('E:\TheForgottenServer 0.2.6\playersRecord.txt'); //Player Record Link to comment Share on other sites More sharing options...
Gatsu Posted October 30, 2007 Author Share Posted October 30, 2007 thank you all =) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.