Sunday 23 October 2016

php - Get all value of h1 tag

I want to get all value of h1 tag and I found this article: getting all values from h1 tags using php



Then I tried to using:



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");
?>


But it's not running and I get:




Notice: Array to string conversion in C:\xampp\htdocs\checker\abc.php
on line 14 Array





Plz help me fix it. I want to get all h1 tag of a website with input data is URL of that website. Thanks so much!

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...