Is there a PHP command to

Is there a PHP command to

am 07.01.2008 19:48:09 von jools

Just wondering what the simplest way to sort IP addresses would be
Is there a good way to sort that keeps them in sequence
asort() sorts on the first character so that doesnt quite do it of course

-jools-

Re: Is there a PHP command to

am 07.01.2008 19:51:33 von Paul Lautman

jools@by.com wrote:
> Just wondering what the simplest way to sort IP addresses would be
> Is there a good way to sort that keeps them in sequence
> asort() sorts on the first character so that doesnt quite do it of
> course
>
> -jools-

Did you wonder enough to type
php sort ip addresses
into google and then press I'm feeling lucky?

Obviously not!

Re: Is there a PHP command to

am 07.01.2008 19:51:44 von luiheidsgoeroe

On Mon, 07 Jan 2008 19:48:09 +0100, wrote:

>
> Just wondering what the simplest way to sort IP addresses would be
> Is there a good way to sort that keeps them in sequence
> asort() sorts on the first character so that doesnt quite do it of course

Convert them to a number (using usort())?
http://nl2.php.net/manual/en/function.ip2long.php
http://nl2.php.net/manual/en/function.long2ip.php
--
Rik Wasmus

Re: Is there a PHP command to

am 07.01.2008 19:52:57 von Michael Fesser

..oO(jools@by.com)

>Just wondering what the simplest way to sort IP addresses would be

You could convert them to a long int, then use normal numeric sorting.

Micha

Re: Is there a PHP command to

am 08.01.2008 11:59:51 von jools

In article <5ufallF1gdopbU1@mid.individual.net>,
paul.lautman@btinternet.com says...
> jools@by.com wrote:
> > Just wondering what the simplest way to sort IP addresses would be
> > Is there a good way to sort that keeps them in sequence
> > asort() sorts on the first character so that doesnt quite do it of
> > course
> >
> > -jools-
>
> Did you wonder enough to type
> php sort ip addresses
> into google and then press I'm feeling lucky?
>
> Obviously not!
>
>
>

All google sites are blocked in my firewall.
I did wonder why newsgroups exist.
I guess you could tell me if you tried?

-jools-

Re: Is there a PHP command to

am 08.01.2008 12:01:51 von jools

In article , luiheidsgoeroe@hotmail.com
says...
> On Mon, 07 Jan 2008 19:48:09 +0100, wrote:
>
> >
> > Just wondering what the simplest way to sort IP addresses would be
> > Is there a good way to sort that keeps them in sequence
> > asort() sorts on the first character so that doesnt quite do it of course
>
> Convert them to a number (using usort())?
> http://nl2.php.net/manual/en/function.ip2long.php
> http://nl2.php.net/manual/en/function.long2ip.php
> --
> Rik Wasmus
>

Aha - I knew there had to be something that helped - thanks Rik.

-jools-

Re: Is there a PHP command to

am 08.01.2008 12:03:02 von jools

In article , netizen@gmx.de
says...
> .oO(jools@by.com)
>
> >Just wondering what the simplest way to sort IP addresses would be
>
> You could convert them to a long int, then use normal numeric sorting.
>
> Micha
>

Pretty much what Rik said - looks like the way to go - thanks Michael.

-jools-

Re: Is there a PHP command to

am 08.01.2008 12:06:41 von Michael Fesser

..oO(jools@by.com)

>All google sites are blocked in my firewall.

Why is that?

You could get many answers much faster if you would do a quick search on
Google or the Google Groups archives. Most questions were already asked
and answered many times before.

>I did wonder why newsgroups exist.

Google it. SCNR

Micha

Re: Is there a PHP command to

am 08.01.2008 12:21:23 von luiheidsgoeroe

On Tue, 08 Jan 2008 12:01:51 +0100, wrote:

> In article , luiheidsgoeroe@hotmail.c=
om
> says...
>> On Mon, 07 Jan 2008 19:48:09 +0100, wrote:
>>
>> >
>> > Just wondering what the simplest way to sort IP addresses would be
>> > Is there a good way to sort that keeps them in sequence
>> > asort() sorts on the first character so that doesnt quite do it of =
=

>> course
>>
>> Convert them to a number (using usort())?
>> http://nl2.php.net/manual/en/function.ip2long.php
>> http://nl2.php.net/manual/en/function.long2ip.php
>> --
>> Rik Wasmus
>>
>
> Aha - I knew there had to be something that helped - thanks Rik.

Hmm, come to think of it...
Allthough not intended for this use, version_compare() would do the tric=
k =

without any problems I think. As the behavious of version_compare is =

clearly defined, and suited for (proven to be valid) IP-addresses, I'd g=
o =

with that:
$array =3D array(
'122.23.45.53',
'12.23.46.53',
'12.23.45.54',
'12.23.45.53',
'12.23.'
'12.23.45.53');
usort($array,'version_compare');
print_r($array);
?>

... unless you also need the insurance the IP adress is valid/stuff like =
=

256 is captured/converted, in which case ip2long is still better.
-- =

Rik Wasmus

Re: Is there a PHP command to

am 08.01.2008 13:12:28 von jools

In article <15m6o3lmevposnr70rdjjtgp51hinqm7d4@4ax.com>, netizen@gmx.de
says...
>
> You could get many answers much faster if you would do a quick search on
> Google or the Google Groups archives. Most questions were already asked
> and answered many times before.
>

which part of the words "blocked" and "firewall" don't you understand?

And no - I seriously doubt I'd get the answers either faster or better on
google even if I could use it as trawling through 30,000 SEO pages of
vaguely on topic rubbish more interested in attracting my attention
than actually telling me anything useful tends to take time and doesnt
have the hands on experience of the users of this group. Nor can it
suggest the "best" method of doing things.

Even if I could use google a newsgroup is always the best place to look
for those and a number of other reasons.

-jools-

Re: Is there a PHP command to

am 08.01.2008 13:24:33 von Paul Lautman

jools@by.com wrote:
> In article <15m6o3lmevposnr70rdjjtgp51hinqm7d4@4ax.com>,
> netizen@gmx.de says...
>>
>> You could get many answers much faster if you would do a quick
>> search on Google or the Google Groups archives. Most questions were
>> already asked and answered many times before.
>>
>
> which part of the words "blocked" and "firewall" don't you understand?
>
> And no - I seriously doubt I'd get the answers either faster or
> better on google even if I could use it as trawling through 30,000
> SEO pages of vaguely on topic rubbish more interested in attracting
> my attention

You will note that when I post a hint about using Google, I usually refer to
the "I'm feeling lucky", button. This button takes you straight to the top
suggestion in the list. I can accept that if you can't find the answer on
the first Google page then maybe it is worth while giving up and asking. But
when the answer is on the first hit, all you do by asking here is have
others look at that article for you.

What a waste of time.

Re: Is there a PHP command to

am 08.01.2008 13:25:49 von jools

In article , luiheidsgoeroe@hotmail.com
says...

> Hmm, come to think of it...
> Allthough not intended for this use, version_compare() would do the tric=
> k =
>
> without any problems I think. As the behavious of version_compare is =
>
> clearly defined, and suited for (proven to be valid) IP-addresses, I'd g=
> o =
>
> with that:
> > $array =3D array(
> '122.23.45.53',
> '12.23.46.53',
> '12.23.45.54',
> '12.23.45.53',
> '12.23.'
> '12.23.45.53');
> usort($array,'version_compare');
> print_r($array);
> ?>
>
> .. unless you also need the insurance the IP adress is valid/stuff like =
> =
>
> 256 is captured/converted, in which case ip2long is still better.

I'll go take a look at that too. Cheers.
Validation isn't a problem - I use the Data Minion DSVE for all my
validations now - it makes life SO much easier! The forms tool even
writes the PHP code for you.
I'd give you the link for it but this isn't my own development machine (I
can't remember it - or google it from here sadly)

-jools-

Re: Is there a PHP command to

am 08.01.2008 14:29:55 von Michael Fesser

..oO(jools@by.com)

>In article <15m6o3lmevposnr70rdjjtgp51hinqm7d4@4ax.com>, netizen@gmx.de
>says...
>>
>> You could get many answers much faster if you would do a quick search on
>> Google or the Google Groups archives. Most questions were already asked
>> and answered many times before.
>>
>
>which part of the words "blocked" and "firewall" don't you understand?

Which part of the word "Why" don't you understand?

>And no - I seriously doubt I'd get the answers either faster or better on
>google even if I could use it as trawling through 30,000 SEO pages of
>vaguely on topic rubbish more interested in attracting my attention
>than actually telling me anything useful tends to take time and doesnt
>have the hands on experience of the users of this group. Nor can it
>suggest the "best" method of doing things.

I also mentioned Google Groups, a Usenet archive.

On for example you
can get all the knowledge and experience of this group's users from the
last couple of years.

>Even if I could use google a newsgroup is always the best place to look
>for those and a number of other reasons.

The best is to do some research on your own first by looking through the
archives or some FAQ sites before annoying the newsgroup regulars and
wasting their time with asking the same questions over and over again.
This is not a help desk.

Micha

Re: Is there a PHP command to

am 10.01.2008 20:49:21 von jools

In article , netizen@gmx.de
says...
>
> The best is to do some research on your own first by looking through the
> archives or some FAQ sites before annoying the newsgroup regulars and
> wasting their time with asking the same questions over and over again.
> This is not a help desk.
>
> Micha
>

So go through this newsgroup and list the dates this question was asked
.... "over and over" - I'll take just the last three -
If you cant do that stop wasting everyones time with your self
opinionated nonesense that has nothing to do with this newsgroup.

This is a newsgroup for questions about PHP. This IS a 'helpdesk'. That
is exactly what it is for.

if YOU cant answer the questions asked here just keep it shut.

-jools-

Re: Is there a PHP command to

am 10.01.2008 22:02:22 von Michael Fesser

..oO(jools@by.com)

>In article , netizen@gmx.de
>says...
>>
>> The best is to do some research on your own first by looking through the
>> archives or some FAQ sites before annoying the newsgroup regulars and
>> wasting their time with asking the same questions over and over again.
>> This is not a help desk.
>
>So go through this newsgroup and list the dates this question was asked
>... "over and over" - I'll take just the last three -

This was not related to your question, but meant in general. Why do you
think many popular newsgroups maintain an FAQ? Just for fun?

>If you cant do that stop wasting everyones time with your self
>opinionated nonesense that has nothing to do with this newsgroup.
>
>This is a newsgroup for questions about PHP. This IS a 'helpdesk'. That
>is exactly what it is for.

You get what you pay for. Oh, you didn't pay for this "help desk"?

>if YOU cant answer the questions asked here just keep it shut.

I already answered your question. For free, BTW! But I have no problem
with keeping my mouth shut if you should ever come along with another
problem. I couldn't care less.

Remember: It's you who wants something from us, not the other way round.

And you still didn't answer my question about why you filter Google,
'cause I don't see any reason for that. But why should I care at all ...

EOT
Micha