View Single Post
Old 08-25-2011, 03:47 PM  
robber
Web Developer
 
Industry Role:
Join Date: Jan 2011
Location: UK
Posts: 264
Morton,

It's simple enough to have it read the file, following on from what was in the previous example, you could get it to read through the information and then include the results so you could almost do: (under the current header info)

Code:
$info = explode(",",file_get_contents(fcheck("info.txt")));
This should read the file and every comma it will put this in a new value in an array, so if your file said:

Quote:
jollyhumper, beer alot, likes
to use the variables from here you just need to echo your array variables so, the following:

Code:
 <?php echo $info[0]." ".$info[2]." ".$info[1]; ?>
Should produce: "jollyhumper likes beer alot" as the variables are set as:

$info[0] = "jollyhumper"
$info[1] = "beer alot"
$info[2] = "likes"

Hope this answers your question (this also uses the revert to default setting), just drop a blank file in with the name and it will mean no errors will come up.

Just one amendment to my original code needs doing, if you drop an @ infront of the file_exists so it reads @file_exists, it basically surpresses any error messages created by the function. (I forgot to add this originally)

If you have any questions about what this is doing and how you can expand it, please ask

Hope this answers your question

Rob

Last edited by robber; 08-25-2011 at 03:49 PM..
robber is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook