I'm trying to store all the H2 tags into my database. I'm using Laravel 5.4 and DomDocument.
How i retrieve the h2 tags:
$htag2 = $dom->getElementsByTagName('h2');
My h2 tags:
<h2> htag2-1 </h2>
<h2> htag2-2 </h2>
<h2> htag2-3 </h2>
<h2> htag2-4 </h2>
This is the output in the database: htag2-4
. As you can see it skips the other 3 h2tags in my xml file.
I'm trying to save this using for loop:
for ($i = 0; $i < $htag2->length; $i++) {
$ts->h2_tag = $htag2->item($i)->nodeValue;
}
Declaration for $ts: $ts = new Scan;
via itvba