I am looking for a function to return an array and all its sub-structure for a specific criteria
Criteria:
- php 5.6 compatible
- Return the last instance of array with key name of
!ENTITYwith all its values in-tact
Sample array:
For the multidimensional array, lets call that $arr, for this example structure it's 6 levels deep, we should not assume it's always 6 levels.
$arr = array("!ENTITY" =>
array("!ENTITY" =>
array("!ENTITY" =>
array("!ENTITY" =>
array("!ENTITY" =>
array("!ENTITY" =>
array("svg" =>
array(
0 => array("g" => "", "@id" => "Layer_2"),
1 => array("g" => "", "@id" => "Layer_3"),
),
"@version" => 1.2,
"@id" => "Layer_1",
),
"@different" => "layer"
),
"@all" => "layer"
),
"@here" => "layer"
),
"@goes" => "layer"
),
"@else" => "layer"
),
"@something" => "layer"
);
Expected Output:
I would like to return the final array for !ENTITY with it's sub-structure all in-tact. Here is a sample of the expected output:
Array
(
[svg] => Array
(
[0] => Array
(
[g] =>
[@id] => Layer_2
)
[1] => Array
(
[g]
[@id] => Layer_3
)
)
[@version] => 1.2
[@id] => Layer_1
)