How to split a space separated file?
- by simplesimon
Hi
I am trying to import this:
http://en.wikipedia.org/wiki/List_of_countries_by_continent_%28data_file%29
which is of the format like:
AS AF AFG 004 Afghanistan, Islamic Republic of
EU AX ALA 248 Åland Islands
EU AL ALB 008 Albania, Republic of
AF DZ DZA 012 Algeria, People's Democratic Republic of
OC AS ASM 016 American Samoa
EU AD AND 020 Andorra, Principality of
AF AO AGO 024 Angola, Republic of
NA AI AIA 660 Anguilla
if i do
<? explode(" ",$data"); ?>
that works fine apart from countries with more than 1 word.
how can i split it so i get the first 4 bits of data (the chars/ints) and the 5th bit of data being whatever remains?
this is in php
thank you