Created
January 28, 2012 10:46
-
-
Save purwandi/1693922 to your computer and use it in GitHub Desktop.
How to get content on html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*$target = 'http://bni.co.id/id-id/informasivalas.aspx'; | |
$ch = curl_init ($target); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
$st = curl_exec ($ch) or die ('Curl Gagal'); | |
curl_close($ch); | |
$p1 = strpos($st, "<td>USD</td><td class=\"number\">"); | |
$p1 = strpos(haystack, needle) | |
echo $st; | |
*/ | |
$target = 'http://www.bankmandiri.co.id/resource/kurs.asp'; | |
$ch = curl_init ($target); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
$st = curl_exec ($ch) or die ('Curl Gagal'); | |
curl_close($ch); | |
$negara = array ('United States Dollar','Euro Rate','Singapore Dollar','Japanese Yen','Australian Dollar'); | |
for ($x = 0; $x < sizeof($negara); $x++): | |
$p1 = strpos($st, $negara[$x]."</span>"); | |
for ($j = 0; $j <= 1; $j++): | |
$p1 = strpos($st, '<td align="right">', $p1 + 1); | |
$p1 = $p1 + 18; | |
$p2 = strpos($st, '</td>', $p1+1); | |
if ($j == 0) $beli = substr($st, $p1, $p2 - $p1); | |
else $jual = substr($st, $p1, $p2 - $p1); | |
endfor; | |
echo '<br /><h2>'.$negara[$x].'</h2><br />'; | |
echo " -- Nilai beli adalah : " . $beli.'<br /> '; | |
echo " -- Nilai jual adalah : " . $jual; | |
endfor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment