Reputation: 3
I'm developing a tool for a client, and I save the data in a txt file when using the tool offline, so that he can then upload this file onto server and save data in database.
The data in the text file are presented like below:
Array
(
[idcategorie] => 1
[idmasteruser] => 1
[societe] => Company
[marque] => Brand
[audit] => AUdit
[nom] => Baker
[prenom] => James
[phone] =>
[email] => [email protected]
[nboutils] => 3
[outil0] => Array
(
[id] => 20
[valeurs] => Array
(
[0] => 24
[1] => 4
[2] => 27
[3] => 16
)
[file] => /newbam/images-up/HopbV_chefs.jpg
[notes] => Array
(
[0] => 4
[1] => 5
[2] => 7
[3] => 6
)
)
)
How can I put this data in a PHP array that I can handle after using keys?
Upvotes: 0
Views: 644
Reputation: 7654
If you used var_dump
to generate this data, restoring it back into an array is a non-trivial task. However, this is much easier if you export the data using var_export
or serialize
, which can be put back into an array.
Upvotes: 1
Reputation: 562
You can serialize the array:
It writes the array in a format that can be saved in a file and parsed later as an object or an array with unserialize:
Hope it helps!
Upvotes: 0