Mega Code Archive

 
Categories / Php / Code Snippets
 

Lookup the symbol for a company

<?php //this is the company you wish to lookup $company = "ntl"; //this is the url from yahoo + the company $url = "http://quote.yahoo.com/l?m=&s=" . $company . "&t="; //open the url and store in $fp $fp = fopen($url , "r"); //read 20000 bytes of the file $readfile = fread($fp , 20000); //search for the HTML below and store everything in between in $content $readfile = ereg("<TABLE border=0 cellPadding=2 cellSpacing=0 width=100%>(.*)<small>Add</small>" , $readfile, $content); //display the results in a table echo "<table width = '100%'>"; echo "$content[1]"; echo "</table>"; //close the file handle fclose($fp); ?>