Splitting strings in file to array
Posted: Wed Sep 05, 2007 3:38 pm
Hi,
I would like to split each strings to an array on a multiple lines file. The file should look like as below:-
------------------------------
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ad0s2a 507630 190196 276824 41% /
devfs 1 1 0 100% /dev
/dev/ad0s2e 507630 20 467000 0% /tmp
/dev/ad0s2f 10154158 5673658 3668168 61% /usr
/dev/ad0s2d 6090094 4987298 615590 89% /var
------------------------------
How do i achieve that? I can use preg_split to split strings in a line to its array but haven't figure out on how to do it on multiple lines file. Each of the string above need to be assign to an array. Better still if there is something like coordinate to help. Eg. "array[1] = (row 2, col 2)"
Any help?
I would like to split each strings to an array on a multiple lines file. The file should look like as below:-
------------------------------
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ad0s2a 507630 190196 276824 41% /
devfs 1 1 0 100% /dev
/dev/ad0s2e 507630 20 467000 0% /tmp
/dev/ad0s2f 10154158 5673658 3668168 61% /usr
/dev/ad0s2d 6090094 4987298 615590 89% /var
------------------------------
How do i achieve that? I can use preg_split to split strings in a line to its array but haven't figure out on how to do it on multiple lines file. Each of the string above need to be assign to an array. Better still if there is something like coordinate to help. Eg. "array[1] = (row 2, col 2)"
Any help?