Gatsu Posted October 29, 2007 Report 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 Report 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 Report 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 Report 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 Report Share Posted October 30, 2007 thank you all =) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now