Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Mengambil nilai dari element html menggunakan php
saya mau mengambil nila dari tag "ul" di "name" terus menjadikannya ke variable php "$src", tapi kok hasilnya kosong ya??
<ul class="collapse list-unstyled" id="<?php echo implode ($dbs);?>" name="<?php echo implode ($dbs);?>">
<?php
$url = "index.php";
$html = file_get_contents($url);
$doc = new DOMDocument(); // create DOMDocument
libxml_use_internal_errors(true);
$doc->loadHTML($html); // load HTML you can add $html
//libxml_clear_errors();
if ($html) {
$name = $doc->getElementsByTagName('ul');
foreach ($name as $name) {
$src = $name->getAttribute('name');
echo $src;
}
?>
<li><a href="#"><?php echo $src; ?></a></li>
<?php
}
?>
</ul>
0