Hi all,
Im having a problem reading CSV data from a text file and storing it in a multidimensional array.
I have a text file like so.
Code:
Cathal|kyle@example.com|83.103.100.300|Wednesday 29th August 2007 @ 17:27-13|66023f4984
tony|tonto@example.com|83.107.82.300|Friday 31st August 2007 @ 12:46-49|1c3fd4594d
steve|imapisces@example.com|86.5.147.300|Friday 31st August 2007 @ 17:22-19|d61f895714
Code:
$file = 'file.txt';
$username = 'bob';
$array = file($file);
foreach($array as $key => $var){
$var = explode('|', $var);
if($username == $var[0]){
$user = $var;
break;
}
}
if(!isset($user))
echo 'No user found';
else echo 'User found';
foreach ($var as $key => $value){
print "<p>key = $key and value = $value</p>";
}
My foreach still just displays the last array (line of text from file)
I am trying very hard to work this one out myself, but I cant get my head around this one.
Hope you can understand what im trying to achive.
If this page receives the username via $_GET I want to find a way of having that username's line of info from the text file in an array for further manipulation.
Any help with this is greatly apreciated.
Regards Kyle
Last edited by homer2k; 09-05-2007 at 04:12 AM..
|