I have this code
$myurl = file_get_contents('https://myurl.html');
$doc = new DOMDocument();
@$doc->loadHTML($myurl);
$divs = $doc->getElementsByTagName('div');
foreach($divs as $div) {
if ($div->getAttribute('id') === 'j-product-desc') {
echo "<br/>".$div->nodeValue;
}
}
Result: It is displaying result something like this with no break line.
Item specifics Item Type: Jewelry Packaging & Display Material: Acrylic Jewelry Packaging & Display Type: Cases & Displays Item Length: 16.5 cm
Required Result I want result like this with break after every specification.
Item specifics
Item Type: Jewelry Packaging & Display
Material: Acrylic Jewelry Packaging & Display
Type: Cases & Displays
Item Length: 16.5 cm