Re: Sorting IP Address Data
| From: | David Robley | Date: | Thu, 23 Aug 2001 06:48:27 +0000 |
| Subject: | Re: Sorting IP Address Data | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64049@lists.php.net to get a copy of this message | ||
On Thu, 23 Aug 2001 12:58, Chris Aitken wrote:
> Hi all,
>
> Just a quick one,
>
> I am pulling a whole Class C list of IP addresses, and im trying to
> sort them in order, but im getting it displayed
>
> 127.0.0.1
> 127.0.0.10
> 127.0.0.100
> 127.0.0.101
> 127.0.0.102
>
> etc. Is there any other way to sort this thinking they are numbers,
> rather than text ?
>
>
> Thanks
>
>
> Chris
Chris
Poke them in an array, and use asort() or sort()with the sortflag
parameter set for numeric. I think that should work.
The optional second parameter sort_flags may be used to modify the
sorting behavior using theese values:
Sorting type flags:
SORT_REGULAR - compare items normally
SORT_NUMERIC - compare items numerically
SORT_STRING - compare items as strings
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
"I'm about to hit the golf ball," Tom forewarned.