Location: PHPKode > scripts > Yahoo Developer > yahoo-developer/Yahoo.inc.php
<?php

class devYahoo{

	var $sSymbol = array(); //Stock Symbol
	var $sQuery;  //Stock Query URL 
	var $Stockcontents;
	var $FinalValue =array();
	
    // Set Stock Symbols
	function setSymbol($tStock){
		$this->sSymbol = $tStock;
		$this->Stock();
	}
	
	function Stock(){  
		 //Building Yahoo Stock Quotes Query
		 $this->Stockcontents = array();
		 $contents = array();
		 for($i=0;$i<count($this->sSymbol);$i++){
			  $this->sQuery = "http://finance.yahoo.com/d/quotes.csv?s=".$this->sSymbol[$i]."&f=sl1d1t1c1ohgv&e=.csv";
			  //$this->sQuery = "http://quote.yahoo.com/d/quotes.csv?s=".$this->sSymbol[$i]."&f=sl1d1t1c1ohgv&e=.csv";
				$fd = fopen ($this->sQuery, "r");
				$tmpVar = fread ($fd, 200);
				array_push($this->Stockcontents,$tmpVar);
				fclose ($fd);
				$tmpvar ="";      
		  } 
		  
		  for($i=0;$i< count($this->sSymbol);$i++){
			  $content = str_replace("\"","",$this->Stockcontents[$i]);
			  $content = explode (",", $content); 
			  array_push($this->FinalValue,$content);
		  }
		  
		  for($i=0;$i<count($this->sSymbol);$i++){
			  for($j=0;$j< count($this->FinalValue[$i]);$j++){
				 if($j == 4){
					$this->DisplayStockImg($this->FinalValue[$i][$j]);
				 }
				 else{
					 echo $this->FinalValue[$i][$j]." ";
				 }
			  }
			  echo "<br>";
		  }
		}	
		
		//Display the Image. Whether the stock is High or Low
		function DisplayStockImg($val){
			if($val == 'N/A'){
			   echo $val." "; return;
			}
			if (substr($val,0,1) == "+"){
				echo '<img src="img/up.gif" alt="up">'.substr($val,1)." ";
			}
			else{
				echo '<img src="img/down.gif" alt="up">'.substr($val,1)." ";		
			}
		}
}

?>
Return current item: Yahoo Developer