R
R
Roman Sokharev2014-02-22 16:19:33
PHP
Roman Sokharev, 2014-02-22 16:19:33

How to convert array listing to array (PHP)?

Bottom line: there is an api with which you need to work. To my sadness, the api returns not XML or JSON or even CSV, but the most common var_dump() array listing. Are there ready-made functions for converting a listing back to an array? Or do you still have to write a regular expression? Do not send to Google - already Googled.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey, 2014-02-22
@greabock

stackoverflow.com/questions/3531857/code-challenge...
following the link, one of the users suggested a solution in which the var_dump output format is first converted to the format in which php serializes objects/arrays, and then this line can be driven into the usual unserialize .
and how you googled it is interesting ... And the creators of the apishka should be ashamed ...

F
FanatPHP, 2014-02-22
@FanatPHP

Hell.
I don't represent such a question in any other community.
Like "I'm an otolaryngologist. Of the instruments, the Gorzdrav brought only an autogen. Can you tell me how to cut out their tonsils?"

V
Vampiro, 2014-02-22
@Vampiro

I would do it in three steps:
1. play around with header: Accept-Encoding
2. knock on tech support and ask to replace var_dump() =>json_encode()
3. google regular expressions, they exist.

S
svd71, 2014-02-22
@svd71

Isn't the usual eval() function right for you?
for example, you saved the text of the external array into the $arrTxt variable. then

eval('$arr='.$arrTxt);
echo print_r($arr);

will output an array of snakes in your local variable $arr.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question