Tue Nov 03, 2009 7:53 pm
$quotes =array('DOW','SPX','GOLD','OIL','AIG','APPLE','AMGN','BAC','DISH',
'DO','DIRECTV','FEDEX','GOOG','HD','IBM','INTEL','IP','COLA','LOWES',
'YEN','EUR' ,'HK','JAP','AUS','INDIA');
//here you can out symbols of stock data
$args = implode('&s=', $quotes);
//$file = fopen("http://finance.yahoo.com/d/quotes.csv?s=$args&f=slp11d1t1c1ohgv&ej3j1x=.csv", "rb");
$file = fopen ("http://finance.yahoo.com/d/quotes.csv?s=$args&f=noc1&ex=.csv","r");
$data = array();
$table = '';
if ($file) {
while($stocks = fgetcsv($file)) {
$data[$stocks[0]] = $stocks;
}
fclose($file);
}
$table .= "<table border='1'>\n";
$table .= "<tr><th colspan='5'>".date('Y-m-d h:i:s A')."</th></tr>\n";
$table .= "<tr>\n";
foreach ($data as $sym => $info) {
$table .= "\t<th>$sym</th>\n";
foreach ($info as $item) {
$table .= "\t<td>$item</td>\n";
}
$table .= (end($data) == $info) ? "</tr>\n" : "</tr>\n<tr>\n";
}
$table .= "</table><br/>";
echo $table;
//file_put_contents('stocks.html', $table, FILE_APPEND);
file_put_contents('C:\stocks.rtf', $table);
Wed Dec 16, 2009 5:51 pm
//echo $table;
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: html");
header("Content-Disposition: attachment;filename=mystock.html;");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($table));
set_time_limit(0);
echo $table;
//file_put_contents('stocks.html', $table, FILE_APPEND);
//file_put_contents('C:\stocks.rtf', $table);
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.