Jump to content

[SOLVED] Ordering Numbers


phrozenflame

Recommended Posts

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/32375-solved-ordering-numbers/
Share on other sites

Q1- If they are in an array, just use the sort() function... If it's a database: use ORDER BY.

For the second question (I am assuming again that the numbers are stored in an array), use the array_keys() function with the optional parameter "search_value":
[code]<?php
//$num contains the number you want to count (how many times it appears)
//$array is the array of numbers

echo count(array_keys($array, $num));

?>[/code]
If it's a database, use COUNT.

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.