Php 使用simplexml\u load\u字符串提取属性
我正在尝试将link的href属性提取为字符串Php 使用simplexml\u load\u字符串提取属性,php,Php,我正在尝试将link的href属性提取为字符串 <a href="http://example.com" target="_blank" class="someclass">Read More</a> 而不是获取http://example.com我得到了href=”http://example.com“。除了使用str_replace()之外,还有什么方法可以将属性提取为字符串?将@attributes视为对象并转换为字符串: $link = simplexml_lo
<a href="http://example.com" target="_blank" class="someclass">Read More</a>
而不是获取
http://example.com
我得到了href=”http://example.com“
。除了使用str_replace()之外,还有什么方法可以将属性提取为字符串?将@attributes
视为对象并转换为字符串:
$link = simplexml_load_string($ad['meta_value']);
echo (string) $link->attributes()->href;
将
@attributes
视为对象并转换为字符串:
$link = simplexml_load_string($ad['meta_value']);
echo (string) $link->attributes()->href;