1zeus1 Posted April 8, 2012 Share Posted April 8, 2012 or need to extract all h1 tags and insert into database You can modify this code to make it work? ////////////////////////////////////////////////////////////////// function getTextBetweenTags($tag, $get, $strict=0) { /*** a new dom object ***/ $dom = new domDocument; /*** load the html into the object ***/ if($strict==1) { $dom->loadXML($get); } else { $dom->loadHTML($get); } /*** discard white space ***/ $dom->preserveWhiteSpace = false; /*** the tag by its tag name ***/ $content = $dom->getElementsByTagname($tag); /*** the array to return ***/ $out = array(); foreach ($content as $item) { /*** add node value to the out array ***/ $out[] = $item->nodeValue; } /*** return the results ***/ return $out; } $content = getTextBetweenTags('h1', $get); foreach( $content as $item ) { $h1 = $item.'<br />'; } $query="UPDATE sitis SET hh = '$h1' WHERE id = '$a'"; //My problem and that puts only a h1 regards Link to comment https://forums.phpfreaks.com/topic/260576-extract/ Share on other sites More sharing options...
dcro2 Posted April 8, 2012 Share Posted April 8, 2012 String Operators $h1 = ""; foreach( $content as $item ) { $h1 .= $item.'<br />'; } Link to comment https://forums.phpfreaks.com/topic/260576-extract/#findComment-1335446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.