#native_company# #native_desc#
#native_cta#

Get Stock Quote’s

By Joe Wilson
on December 16, 2000

Version: .5

Type: Full Script

Category: Money

License: GNU General Public License

Description: This little script will grab stock quote info from finance.yahoo.com. The script is kind of crude. Something I wrote while learning php.

[email protected]

<?

$quotes[] = "msft";
$quotes[] = "amzn";
$quotes[] = "macr";
$quotes[] = "rhat";
$quotes[] = "orcl";

$indexLimit = count($quotes);

print("<table>");
for($index=0; $index<$indexLimit; $index++) {
  $quote = $quotes[$index];
  $file = "http://finance.yahoo.com/d/quotes.csv?s=$quote&f=sl1d1t1c1ohgv&e=.csv";
  if($myFile = fopen("$file","r")) {
  	 while (!feof ($myFile)) {
    print("<tr>n");
      $myField = fgetcsv($myFile, 1024);
      for($n=0; $n<count($myField); $n++) {
        print("<td>");
        if($n == "0"){
          print("<b>$myField[$n]</b>");
        } else {
          print("$myField[$n]");
        }
        print("</td>n"); 
      }
    print("</tr>n");
    }
    fclose($myFile);
  }
}
print("</table>");

?>