All,
So I have a text file I'm reading into an array that looks like this:
TEST.TXT
00501 NYHoltsville Suffolk 840
00544 NYHoltsville Suffolk 840
00601 PRAdjuntas Adjuntas 840
00602 PRAguada Aguada 840
00603 PRAguadilla Aguadilla 840
I read this into an array using this snippet:
if ($zips=file("test.txt")){
$i=0;
foreach($zips as $zip){
echo "\$zips[$i] => $zip.\n";
$i++;
}
}
My output is this:
zips[0] => 00501 NYHoltsville Suffolk 840 . $zips[1] => 00544 NYHoltsville Suffolk 840 . $zips[2] => 00601 PRAdjuntas Adjuntas 840 . $zips[3] => 00602 PRAguada Aguada 840 . $zips[4] => 00603 PRAguadilla Aguadilla 840 .
What I want to do is break the index up so say, zips[0] would be $zipc =00501, $state=NY, $city=Holtsville, $county=Suffolk, $countryCode=840.
I have read chapters on arrays and consulted php.net but I feel the answer is eluding me and perhaps I don't know what to look for exactly.
Any help is appreciated! Thanks so much! in advance. You can email me at playa86 AT gmail DoT com.