drxnfdx798517235 2017-11-29 13:54
浏览 34

如何从svg合并数组导致php?

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") {
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端