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