Re: Determine variable with the lowest value?

From: Date: Thu, 14 Oct 2004 03:26:39 +0000
Subject: Re: Determine variable with the lowest value?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-199457@lists.php.net to get a copy of this message
Thanks guys. Yes I figured using an array and the MIN function would be a start. Now the random part..... "Boot" <pfine@of-law.com> wrote in message news:20041013221858.60629.qmail@pb1.pair.com... > Any help with this would be appreciated. > > I am trying to come up with something that will find which variable(s) have > the lowest value and inidicate which variable this is. In the event that > variables have an equally low value then it is to randomly pick one of the > variables and idicate which this is. > > I have been able to do this by means of if comparisons but the more I > variables I add then the more complicated and messy it becomes. There has to > be a simpler way. If it makes any difference, the variables could just as > easily be array elements. > > example: > > $a = 2 > $b =2 > $c= 4 > $d= 5 > $e=6 > $f =7 > > the code should determine that $a and $b have the lowest value, and randomly > pick one of them. if $a was = 1 instead then it would just pick $a > > > Thanks for any suggestions!

« previous php.general (#199457) next »