I need some help and I gladly appreciate any i can get
I am reading a file and putting the data into an array
$data = file('test.txt');
foreach ($data as $line){
$fields = explode("\t", $line);
$id = $fields[0];
$name = $fields[2];
$street = $fields[3];
$city = $fields[7];
$state= $fields[8];
$zip = $fields[9];
$country = $fields[10];
if ($country == 'United States') {
$ushotels = $line;
foreach ($ushotels as $usdata){
$fields = explode("\t", $usdata);
$uscountry = $usdata[10];
echo $uscountry;
}
} else {
$foreignhotels = $line;
}
}
?>
the 10th level or field of the file is a country, what I am trying to do is that if the county equals the 'United States', i want to write the contents of the orginal $data file to one array
and
if the country does not equal 'United States' place the $data into another array
I know my code looks like $@#@, but I am new to this
can someone help me out please..................
Regards
Mike