Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用simple_html_dom.php获取纯文本值?_Php - Fatal编程技术网

如何使用simple_html_dom.php获取纯文本值?

如何使用simple_html_dom.php获取纯文本值?,php,Php,我想得到以下强元素的值“hello”,唯一唯一的值是em类名,强元素的类名可能重复,如何通过simple_html_dom.php获得“hello” 我 通过 $html->find('em[class=b]') 只是“嗨”,不是我想要的,有人通过简单的html dom有好主意吗?谢谢 <strong class="a"> <em class="b">hi</em> hello </strong> 你好 你好 试试这个: $elem

我想得到以下强元素的值“hello”,唯一唯一的值是em类名,强元素的类名可能重复,如何通过simple_html_dom.php获得“hello” 我 通过

$html->find('em[class=b]') 
只是“嗨”,不是我想要的,有人通过简单的html dom有好主意吗?谢谢

<strong class="a">
<em class="b">hi</em>
hello
</strong>

你好
你好

试试这个:

$element = $html->find('em[class=a]');
$element->innertext;

实际上我还没有测试过,但它应该可以基于

看看这个库或Hi Vince,谢谢你的回复,我已经尝试过了,但它不起作用。还有其他建议吗?谢谢