SimpleXML Attributes to Array

前端 未结 5 1017
臣服心动
臣服心动 2020-12-15 05:19

Is there any more elegant way to escape SimpleXML attributes to an array?

$result = $xml->xpath( $xpath );
$element = $result[ 0 ];
$attributes = (array)          


        
5条回答
  •  旧时难觅i
    2020-12-15 05:48

    a more elegant way; it gives you the same results without using $attributes[ '@attributes' ] :

    $attributes = current($element->attributes());
    

提交回复
热议问题