This question I ask because of a difficulty that I find especially answering questions right here.
When sharing the result of print_r
of an array, for example:
Array
(
[0] => Array
(
[dim1] => Array
(
[dim1.1] => valor1.1
[dim1.2] => valor1.2
)
)
[1] => Array
(
[dim2] => Array
(
[dim2.1] => valor2.1
[dim2.2] => valor2.2
[dim2.3] => valor2.3
)
)
)
Interesting to have the original array, for example to do code tests.
Is there a proper PHP function to revert the original array from print_r
regardless of the structure or dimensions of the array?
Is there any other way to do it?
For example:
The result you want to obtain from the print_r
indicated above would be a variable like this:
$array=array(
array("dim1"=>array ("dim1.1"=>"valor1.1", "dim1.2"=>"valor1.2")),
array("dim2"=>array ("dim2.1"=>"valor2.1", "dim2.2"=>"valor2.2", "dim2.3"=>"valor2.3"))
);
But, it's about finding a function that converts any
print_r
output to your original array .