Chris,

Understand the problem now.

All you need to keep is the last octect of the IP Address.

The following code snippet generates an array entry for each ip. The array is
then sorted and the result prepended with the base IP.

<?
$strBaseIP = "127.0.0.";
    for ($i=0;$i<=255;$i++) {
     $strIP = $i;
     print "IP = $strIP<br>";
     $aryIP[$i] = $strIP;
}
sort($aryIP);
for ($i=0;$i<=255;$i++) {
     $strIP = $strBaseIP.$aryIP[$i];
 print "IP = $strIP<br>";
}
?>

Pretty rough and ready but it should point you in the right direction.

If you need to sort IP's from differnet subnets then you need to split the IP as
per the previous suggestion.

Chris

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 Aitken - Administration/Database Designer - IDEAL Internet
>   email: [EMAIL PROTECTED]  phone: +61 2 4628 8888  fax: +61 2 4628 8890
>               __-----------------------------------------__
>                            *** Big Brother ***
> It just shows that the dull will rule the world. And we will be watching it.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

--

Chris Fry
Quillsoft Pty Ltd
Specialists in Secure Internet Services and E-Commerce Solutions
10 Gray Street
Kogarah
NSW  2217
Australia

Phone: +61 2 9553 1691
Fax: +61 2 9553 1692
Mobile: 0419 414 323
eMail: [EMAIL PROTECTED]
http://www.quillsoft.com.au

You can download our Public CA Certificate from:-
https://ca.secureanywhere.com/htdocs/cacert.crt

**********************************************************************

This information contains confidential information intended only for
the use of the authorised recipient.  If you are not an authorised
recipient of this e-mail, please contact Quillsoft Pty Ltd by return
e-mail.
In this case, you should not read, print, re-transmit, store or act
in reliance on this e-mail or any attachments, and should destroy all
copies of them.
This e-mail and any attachments may also contain copyright material
belonging to Quillsoft Pty Ltd.
The views expressed in this e-mail or attachments are the views of
the author and not the views of Quillsoft Pty Ltd.
You should only deal with the material contained in this e-mail if
you are authorised to do so.

This notice should not be removed.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to