Re: Help with Numbers
| From: | Christopher J. Crane | Date: | Wed, 02 Oct 2002 19:52:50 +0000 |
| Subject: | Re: Help with Numbers | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-118648@lists.php.net to get a copy of this message | ||
Thank you very much, I did not know sort would work this way. Makes complete
sense now though. Thansk again I will give it a shot.
"Rasmus Lerdorf" <rasmus@php.net> wrote in message
news:Pine.LNX.4.44.0210021248210.27901-100000@www.lerdorf.com...
> Sort the arrays and pick off the first and last elements.
>
> On Wed, 2 Oct 2002, Christopher J. Crane wrote:
>
> > 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.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>