Help with Numbers

From: Date: Wed, 02 Oct 2002 19:46:53 +0000
Subject: Help with Numbers
Groups: php.general 
Request: Send a blank email to php-general+get-118642@lists.php.net to get a copy of this message
I am looking for a way to find the highest 5 and lowest 5 numbers within 300 or so numbers. Here is what I have so far... $Tickers = array(); $Current = array(); // SQL QUERY TO GET TICKERS MSSQL_CONNECT($HostName,$UserName,$Password); mssql_select_db($DBName) or DIE("Table unavailable"); $Results = MSSQL_QUERY("SELECT CompanyName,Ticker FROM Company WHERE Ticker != ''"); $RowCount = MSSQL_NUM_ROWS($Results); print "$RowCount Number of Tickers<br>\n"; if($RowCount != 0) { for ($i = 0; $Field = MSSQL_FETCH_ARRAY($Results); ++$i) { array_push($Tickers, $Field["Ticker"]); } } else { print "There was nothing selected in the Query, it may have been bad."; } foreach($Tickers as $Ticker) { Get Last price on the ticker from database. and... array_push($Current, $Value); } Now that I have the values in an array I would like to pull out the five highest and the 5 lowest. Is there a way to do that....if not, is there another way to do what I am looking for. I keep thinking I would have to compare each ticker against all the others to verify it's standing...and that seems like a lot of work.

« previous php.general (#118642) next »