PHP – Display Microsoft Stock Quotes

The given PHP example display the stock quotes from a CSV file, in this case Microsoft. 

Code Example:
<?php 

//this is the url for Microsoft's stock quote , we are opening it for reading 
$fp = fopen ("http://finance.yahoo.com/d/quotes.csv?s=msft&f=sl1d1t1c1ohgv&e=.csv","r"); 
$data = fgetcsv ($fp, 1000, ",") 
?> 
<table> 
<tr><td>Description</td><td>Latest Figures</td><tr> 
<tr><td>Symbol</td><td><?php echo $data[0] ?></td></tr> 
<tr><td>Last Price</td><td><?php echo $data[1] ?></td></tr> 
<tr><td>Date</td><td><?php echo $data[2] ?></td></tr> 
<tr><td>Time</td><td><?php echo $data[3] ?></td></tr> 
<tr><td>Change</td><td><?php echo $data[4] ?></td></tr> 
<tr><td>Open</td><td><?php echo $data[5] ?></td></tr> 
<tr><td>High</td><td><?php echo $data[6] ?></td></tr> 
<tr><td>Low</td><td><?php echo $data[7] ?></td></tr> 
<tr><td>Volume</td><td><?php echo $data[8] ?></td></tr> 
</table> 
<?php 
fclose ($fp); 
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *