I have some data which I retrieve via an API, 2 examples are attached.
I want a PHP script to sanitise the data so each relevant bit of information can be mapped into a variable ready for posting to a database.
Once the script is written it should hopefully automatically read the contents of a text file and then map them into a list of relevant variables.
Also note that there will be arbitrary numbers of products, so for example one order might just have one product ("product-1"), while another might have 3 for example ("product-1:, "product-2", "product-3").
If you need a specific list of variables I want the data to be mapped to then please let me know.
So for example I want it to use this:
to output this