note 23940 added to function.fopen
| From: | oki at creative-labs dot org | Date: | Thu, 01 Aug 2002 21:01:00 +0000 |
| Subject: | note 23940 added to function.fopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-34107@lists.php.net to get a copy of this message | ||
This is sample fopen() script to grabber exchange rates from www.klikbca.com :
<?
$url = "http://www.klikbca.com/website/indo/price_rate/exchange_rate.html";
// Trailing slash when not using filename
$html_start = "<table border=\"0\" cellpadding=\"2\"
cellspacing=\"2\" width=\"100%\">";
$html_end = "<!--- Mulai proses untuk yang BN----->";
// Start grabber of content
ini_set('max_execution_time', '0');
flush ();
$fd= fread(fopen("$url", "r"), 9999);
if ($fd)
{
$a = strpos($fd, "$html_start");
$b = strpos($fd, "$html_end");
$c = $b-$a;
$show = Substr($fd, $a, $c);
}
// Editing html code
$show = ereg_replace("<table border=\"0\" cellpadding=\"2\"
cellspacing=\"2\" width=\"100%\">", "<table border=0
cellspacing=1 cellpanding=0 width=200>", $show);
// Show finish code
echo "<h2>Exchange Rates : \$US-Rp</h2>\n";
echo $show;
flush ();
?>
Easy and fast! :)
http://www.creative-labs.org/php/
--
http://www.php.net/manual/en/function.fopen.php
http://master.php.net/manage/user-notes.php?action=edit+23940
http://master.php.net/manage/user-notes.php?action=delete+23940
http://master.php.net/manage/user-notes.php?action=reject+23940