0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You can serialize the array:

http://php.net/serialize

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:

http://php.net/unserialize

Hope it helps!

1 Comment

Thank you easy and simple ! Perfect !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.