I have tried to merge two different array but the output showing empty arrays. i would like to merge into single array so that i can loop foreach results and show it on my front-end. the results are from svg. i already did it using json_encode. Please check with my below code and advise on this. There are two or more arrays will be there
Array
(
[@attributes] => Array
(
[id] => Layer_1
[data-name] => Layer 1
[viewBox] => 0 0 72 72
[width] => 234
[height] => 170
[preserveAspectRatio] => none
)
[defs] => Array
(
[style] => .cls-1{fill-rule:evenodd;}
)
[title] => Arrow 20
[path] => Array
(
[@attributes] => Array
(
[class] => cls-1
[d] => M70.47,34.06,48.11,11.7a2.75,2.75,0,0,0-4.69,1.94l1.72,11.93h-34a10.43,10.43,0,0,0,0,20.86h34L43.42,58.37a2.76,2.76,0,0,0,2.75,2.74,2.77,2.77,0,0,0,1.94-.8L70.47,37.94a2.73,2.73,0,0,0,0-3.88Z
[fill] => #000000
)
)
)
-
Array
(
[@attributes] => Array
(
[id] => Layer_1
[data-name] => Layer 1
[viewBox] => 0 0 72 72
[width] => 160
[height] => 99
[preserveAspectRatio] => none
)
[defs] => Array
(
[style] => .cls-1{fill-rule:evenodd;}
)
[title] => Arrow 18
[polygon] => Array
(
[@attributes] => Array
(
[class] => cls-1
[points] => 71.28 36 55.49 20.21 55.49 31.19 0.72 31.19 0.72 40.81 55.49 40.81 55.49 51.79 71.28 36 71.28 36
)
)
)
Code:
$result_test = array();
print '<pre>';
print_r($svg_array_values);
//exit;
foreach($svg_array_values as $item) {
$result_test = array_merge($result_test, $item);
}
print '<pre>';
print_r($result_test);
foreach($result_test as $key => $svg_all_values) {
//print '<pre>';
//echo $key;
//print_r($result_test);
//echo "Y".$result_test['text']['@attributes']['y'];
if ($key=="text") {
}
}