The-Last-Escape Posted May 3, 2007 Share Posted May 3, 2007 I've got a list of about 350+ numbers, and there' in the 700-800's, but I'd like to know how to do a ffew things: Order them form least to greatest AND // OR Count how many times each number appears, and display the results. How would I go about doing this? Link to comment https://forums.phpfreaks.com/topic/49850-odering-numbers/ Share on other sites More sharing options...
pocobueno1388 Posted May 3, 2007 Share Posted May 3, 2007 Are these numbers stored in a database, flat-file, or what? Link to comment https://forums.phpfreaks.com/topic/49850-odering-numbers/#findComment-244551 Share on other sites More sharing options...
genericnumber1 Posted May 3, 2007 Share Posted May 3, 2007 <?php $numbers = array(1, 30, 29, 3, 9, 12, 30, 1, 30); sort($numbers, SORT_NUMERIC); print_r($numbers); /* Array ( [0] => 1 [1] => 1 [2] => 3 [3] => 9 [4] => 12 [5] => 29 [6] => 30 [7] => 30 [8] => 30 ) */ $numCount = array_count_values($numbers); print_r($numCount); /* Array ( [1] => 2 [3] => 1 [9] => 1 [12] => 1 [29] => 1 [30] => 3 ) */ ?> Link to comment https://forums.phpfreaks.com/topic/49850-odering-numbers/#findComment-244555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.