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? Quote Link to comment 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? Quote Link to comment 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 ) */ ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.