Moptop650 Posted February 9, 2007 Share Posted February 9, 2007 If I have an array with different numbers in it ex: $w[1]=13; $w[2]=68; $w[3]=43; Useing max(); [Or not with that function, I dunno] how would I be able to print out 2 is the highest Link to comment https://forums.phpfreaks.com/topic/37699-max-q/ Share on other sites More sharing options...
trq Posted February 9, 2007 Share Posted February 9, 2007 <?php $a = array(13,68,43); $return = array_keys($a,max($a)); echo "{$return[0]} is the highest"; ?> Link to comment https://forums.phpfreaks.com/topic/37699-max-q/#findComment-180308 Share on other sites More sharing options...
artacus Posted February 9, 2007 Share Posted February 9, 2007 rsort() $w[0] Link to comment https://forums.phpfreaks.com/topic/37699-max-q/#findComment-180309 Share on other sites More sharing options...
Moptop650 Posted February 9, 2007 Author Share Posted February 9, 2007 <?php $a = array(13,68,43); $return = array_keys($a,max($a)); echo "{$return[0]} is the highest"; ?> Thanks! That worked. rsort() $w[0] Uh...? Link to comment https://forums.phpfreaks.com/topic/37699-max-q/#findComment-180311 Share on other sites More sharing options...
trq Posted February 9, 2007 Share Posted February 9, 2007 That Outputs 'Array is the highest' for me. It shouldn't. I did modify my code a little (edited post). Link to comment https://forums.phpfreaks.com/topic/37699-max-q/#findComment-180314 Share on other sites More sharing options...
Moptop650 Posted February 9, 2007 Author Share Posted February 9, 2007 Well I tried it once and it didn't, then tried again and it did, I guess I got the edited post the 2nd time. Link to comment https://forums.phpfreaks.com/topic/37699-max-q/#findComment-180322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.