one solution that works on all ip numbers
<?
$ip = 
array("192.168.132.3","192.168.132.2","0.0.0.1","192.168.132.4","192.168.1.1","192.168.0.1");
foreach($ip as $val){
         $split = explode(".",$val);
         $num = (16777216 * $split[0]) + (65536 * $split[1]) + (256 * 
$split[2]) + $split[3];
         $iplist["$num"] = $val; //quotes needed to force it into assoc 
type array (php4.0.4)
}
ksort($iplist,SORT_NUMERIC );
reset($iplist);
foreach($iplist as $val){
         echo $val."<br>";
}
?>

At 01:28 PM 23/08/01, 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]


-- 
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