gpt4 book ai didi

php - 使用 PHP 遍历 SVG 元素

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:59:22 24 4
gpt4 key购买 nike

<分区>

如何使用 PHP 遍历 SVG 元素?

<?php

$svgString = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow: hidden; position: relative;" width="9140" version="1.1" height="3050">
<rect x="0" y="0" width="9140" height="3050" r="0" rx="0" ry="0" fill="#FFFF00" stroke="#000"/>
<image x="-101.5" y="-113.5" width="203" height="227" xlink:href="1.jpg" stroke-width="1"></image>
<image x="-201.5" y="-213.5" width="103" height="127" xlink:href="2.jpg" stroke-width="1"></image>
</svg>';

$svg = new SimpleXMLElement( $svgString );
$result = $svg->xpath('//image');
echo count( $result );
for ($i = 0; $i < count($result); $i++)
{
var_dump( $result[$i] );
}

count($result) 返回 0,因此循环被省略。

我做错了什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com