Skip to content Skip to sidebar Skip to footer

How To Fetch The Innerhtml Code From Html Table Using Php

I am able to parse HTML page properly, but it is parsing just the data whereas I want to fetch entire HTML code inside in , . Below is my PHP code:

Solution 1:

in your second for loop:

foreach ($rowsas$row)   
{   
   // get each column by tag name  $cols = $row->getElementsByTagName('td');   
    $row = array();
    $i=0;
    foreach ($colsas$node) {
        # code...if($row_headers==NULL)
            $row[] = $node->nodeValue;
        else$row[$row_headers[$i]] = $node->firstChild->ownerDocument->saveHTML($node->firstChild);
        $i++;
    }   
    $table[] = $row;
}   

than the output will be:

[1] => Array
(
    [Column 1] => <b>Q</b>
    [Column 2] => Desc.
)

Post a Comment for "How To Fetch The Innerhtml Code From Html Table Using Php"