here is the code:
Code: Select all
<php?
//get stock price using yahoo finance api, uses csv format
$ticker = "http://download.finance.yahoo.com/d/quotes.csv?s=" . $_GET["stock"] . "&f=sl1d1t1c1ohgv&e=.csv";
if (($handle = fopen($ticker, "r")) !== FALSE) {
$data = fgetcsv($handle, 1000, ","));
//splits up code to get the actual price
$actual_price = explode(",", $data[0]);
//actually shows the stock price:
echo $actual_price[1];
}fclose($handle);
?>