Forum Moderators: coopster

Message Too Old, No Replies

$category = "whatever variable has the highest number";

         

Hero_Doug

4:28 am on Dec 20, 2003 (gmt 0)

10+ Year Member



I have a bunch of variables containing numeric values.

I want to make a statement like this

$variable1 = 1;
$variable2 = 44;
$variable3 = 3;
$variable4 = 67;
$variable5 = 78;

$category = "whatever variable has the highest number";

IanKelley

7:37 am on Dec 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use an array instead of strings and then sort the array numerically descending. $array[0] will then be the highest number.

Hero_Doug

12:37 pm on Dec 20, 2003 (gmt 0)

10+ Year Member



thanks

phpologist

2:37 pm on Dec 20, 2003 (gmt 0)

10+ Year Member



also, see the max() function:
[uk.php.net...]

bobnew32

5:48 am on Dec 21, 2003 (gmt 0)

10+ Year Member



Use an array instead of strings and then sort the array numerically descending. $array[0] will then be the highest number.

How would you do that?

IanKelley

6:28 am on Dec 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



rsort($array);