1
我想h1标签的所有值h1标签的所有价值,我发现这篇文章:getting all values from h1 tags using php获取
然后我试图使用:
<?php
include "functions/simple_html_dom.php";
function getTextBetweenTags($string, $tagname) {
// Create DOM from string
$html = str_get_html($string);
$titles = array();
// Find all tags
foreach($html->find($tagname) as $element) {
$titles[] = $element->plaintext;
}
return $titles;
}
echo getTextBetweenTags("http://mydomain.com/","h1");
?>
但它没有运行,我得到:
通知:Array对字符串的转换在C:\ XAMPP \ htdocs中\检查\ abc.php 第14行阵列
Plz帮我修复它。我想获得输入数据的网站的所有h1标签是该网站的URL。非常感谢!
'getTextBetweenTags'返回一个数组。使用'print_r()'来检查结果 – user1978142