I am trying to parse a file using php, but I'm not sure if this is the best way to do this. A file consists of files such as:
saturn+5 57 space+shuttle 34 gemini 12 mercury 2 soyuz+tm 1
What I'm trying to do is split it up and populate the hash map, so ..
$inventory["saturn+5"] = "57";
$inventory["space+shuttle"] = "34";
and so on.
I do not know how to solve this.
I am trying to write a bit of regular expression to process a file to highlight fields, but I was not very lucky and I was wondering if I was trying to use a different approach using split()or explode().
source
share