one solution that works on all ip numbers
";
}
?>
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
>12
And if the numbers are from different subnets, you could sort like so
(assuming addresses are in a 1-dimensional array, here called
$IpAddresses):
function sort_address($IpAddresses) {
$List = array();
foreach ($IpAddresses as $A) {
list($x,$y,$z,$t) = explode('.', $A);
$L
And if the numbers are from different subnets, you could sort like so
(assuming addresses are in a 1-dimensional array, here called
$IpAddresses):
function sort_address($IpAddresses) {
$List = array();
foreach ($IpAddresses as $A) {
list($x,$y,$z,$t) = explode('.', $A);
$L
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
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.
";
$aryIP[$i] = $strIP;
}
sort($aryIP);
for ($i=0;$i<=255;$i++
Chris,
What order are you trying to achieve? These look to be in order?
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
>
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 ?
Than
7 matches
Mail list logo