Creating array with text file contents
Posted: Fri Feb 20, 2004 3:23 pm
Hi,
I would like to get the contents from a text file, and add certain peices of data to an array. I don't have a problem with reading the text file, but I can't work out how to seperate the peices of data in the text file. I thought maybe I could create a text file containing the following:
"DY","LS",User3"
And adding the following code to my PHP script:
But it just displays the whole of the textfile. I would appreciate if someone could come up with a solution,
Thanks, luke.
I would like to get the contents from a text file, and add certain peices of data to an array. I don't have a problem with reading the text file, but I can't work out how to seperate the peices of data in the text file. I thought maybe I could create a text file containing the following:
"DY","LS",User3"
And adding the following code to my PHP script:
Code: Select all
<?php
$filename = "users.txt";
$file = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($file);
$users = array($contents);
echo($usersї0]);
?>Thanks, luke.