Let's say I have this output from some source where I don't have access to the original PHP created array:
Array
(
[products] => Array
(
[name] => Arduino Nano Version 3.0 mit ATMEGA328P
[id] => 10005
)
[listings] => Array
(
[category] =>
[title] => This is the first line
This is the second line
[subtitle] => This is the first subtitle
This is the second subtitle
[price] => 24.95
[quantity] =>
[stock] =>
[shipping_method] => Slow and cheap
[condition] => New
[defects] =>
)
[table_count] => 2
[tables] => Array
(
[0] => products
[1] => listings
)
)
Now I would like to input that data and have an algorithm recreate the original array that it was printing so I can then use it for my own application.
Currently I am thinking about a sub_str()
and regex statements that pull data and place it appropriately. Before I head further, is there a simpler way, via already written code or php plugins that do this for me already out there?
I also worked out a solution for your problem because it is a very useful tool to recreate issues here on Stack Overflow. My source is located here: https://github.com/etalon/aprp
I did it a bit different: In your string you don't need line-breaks, so I walk through the chars. One disatvantage: If there are brackets or parenthesis in your array-values it won't work.
not my code, found here in the comments: print_r 'Matt' is the owner