I am trying to take data from a text file that is formatted like this:
name of person
123 address st
city state country zip
name of person2
1234 address st
city state country zip
etc..
and put it into an array so that I can put it in to a DB or return it as csv,
I found a way to show the data but not in a way that allows me to manipulate it so that I can extract the three lines (name, address, location info)
My thoughts are to make a multidimensional array so that I can easily access the info but I can't quite figure out how.
Here is what I have so far (without the multidimensional array)
$fp=fopen("the_text_file.txt","r");
while(!feof($fp)) {
$line=fgets($fp,256);
list($key,$value) = split("\r",$line);
$array[$key] = $value;
}
fclose($fp);
while(list($key,$value) = each($array)) {
echo "$key <br />";
}
this basically just opens and reads the file and prints everything out but does not give me a way to format a query from the data.
any ideas?
thanks!