Postingan lainnya
Buku Ini Koding!
Baru!
Buku ini akan jadi teman perjalanan kamu belajar sampai dapat kerjaan di dunia programming!
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Tentang simple_html_dom.php
Cara menghilangkan "1 Gold = US $" gmana yh ini code saya
<?php
include('simple_html_dom.php');
$url = 'https://www.g2g.com/wow-us/gold-2299-19249?&server=30805&faction=543&sorting=price@asc';
//masuk ke web html
$html = file_get_html($url);
//cari rate harga
foreach($html->find('span[class^="products__exch-rate"]') as $span) {}
echo $span->innertext.'<br />';
?>
SS
10 Jawaban:
Halo sucyresky, Mohon Izin menjawab
kamu bisa gunakan str_replace dengan empty string ""
Simulasi: <pre> $my_str = '1 Gold = US $0.243252332';
echo str_replace("1 Gold = US $", "", $my_str); </pre>
output: <pre> 0.243252332 </pre>
untuk di code anda bisa diubah dibagian ini: <pre> echo str_replace("1 Gold = US $", "", $span->innertext).'<br />'; </pre>
Semoga dapat menjawab, Regards
Ngg bisa mas karna ratenya itu berubah-ubah terus
<img src='https://i.ibb.co/0nZsGB8/cats.jpg'>
iyaa mas, tinggal dirubah saja variable nya jadi spt ini:
<pre> <?php include('simple_html_dom.php');
$url = 'https://www.g2g.com/wow-us/gold-2299-19249?&server=30805&faction=543&sorting=price@asc'; //masuk ke web html $html = file_get_html($url); //cari rate harga foreach($html->find('span[class^="products__exch-rate"]') as $span) {}
echo str_replace("1 Gold = US $", "", $span-&gt;innertext).'&lt;br /&gt;';
?> </pre>
rate nya akan tetap berubah2
"1 Gold = US $" tapi tetap saja masih muncul mas
https://goldmasterid.000webhostapp.com/G2G/index2.php
kenapa gk ngambil value dari tag span[data-ppu] ???
penulisan kodenya gmana mas, klo di ambil dari "data-ppu"
Jawaban Terpilih
Mungkin seperti ini : <pre> foreach($html->find('span[data-ppu]') as $span) { echo $span->innertext.'<br />'; } </pre>