I am trying to get the <td>
from a specific row, but I always encounter the Warning: Invalid argument supplied for foreach()
error.
MY CODE:
$dom = new domDocument;
@$dom->loadHTML($notes); #$notes - value of textarea
$dom->preserveWhiteSpace = false;
$rows = $dom->getElementsByTagName('tr');
$moths = $rows->item(0)->nodeValue; #first row
$mothlast = $rows->item($rows->length - 1)->nodeValue; #lastrow
foreach ($moths as $moth)
{
$cols_mother = $moth->getElementsByTagName('td'); trying to get the columns of the first row of table
$rli_mother = strip_tags($cols_mother->item(0)->nodeValue);
echo $rli_mother; #first row
}
Any help would be gladly appreciated. thank you!!!