arrays - PHP: parse structured txt file -
i have text file has structure it. use php take of values keys in structure , add them array. value object. advice on function parse this?
object: 32.5445213,-92.0041885 icon: 0,0,000,6,6,"dude 1 (wx)\n2013-05-14 14:05:45 utc\nstationary\nemail: dude@dude.com\nweb: www.dude.com\nmscas" text: 15, 10, 1, "dude 1" end: object: 34.2017555,-90.5699615 icon: 0,0,000,6,6,"dude 1 (wx)\n2013-05-14 14:05:45 utc\nstationary\nemail: dude@dude.com\nweb: www.dude.com\nmscas" text: 15, 10, 1, "dude 1" end: object: 42.1689987,-88.2949982 icon: 0,0,000,6,6,"dude 1 (wx)\n2013-05-14 14:05:45 utc\nstationary\nemail: dude@dude.com\nweb: www.dude.com\nmscas" text: 15, 10, 1, "dude 1" end: object: 48.1980019,-101.3073273 icon: 0,0,000,6,6,"dude 1 (wx)\n2013-05-14 14:05:45 utc\nstationary\nemail: dude@dude.com\nweb: www.dude.com\nmscas" text: 15, 10, 1, "kc0isw" end: object: 34.1373138,-88.7238998 icon: 0,0,000,6,6,"dude 1 (wx)\n2013-05-14 14:05:45 utc\nstationary\nemail: dude@dude.com\nweb: www.dude.com\nmscas" text: 15, 10, 1, "dude 1" end:
do if you'd parse in c: fscanf
. it's easiest , safest
$file = fopen("filename", "r"); $data = array(); while (fscanf($file, "object: %s\n", $object)) { $data[] = $object; // explode(",", $object); // or if need explode commas }
Comments
Post a Comment