SOLVED: ksort
Posted: Wed Feb 22, 2012 11:41 am
I'm new to PHP!
I am writing a script to sort new entries pasted into a hosts file into ascending IPv4 address order. The script works fine, and (to my surprise) eliminates any duplicate entries.
I say 'to my surprise' because I haven't (yet) written any explicit code to eliminate duplicate entries; the ksort function (operating on the decimal numerical value of the IP addresses as keys) seems to take care of this automatically.
Should I have expected this? Or am I just lucky?! Always nervous of the unexpected, even if it's good news!
With thanks.
I am writing a script to sort new entries pasted into a hosts file into ascending IPv4 address order. The script works fine, and (to my surprise) eliminates any duplicate entries.
I say 'to my surprise' because I haven't (yet) written any explicit code to eliminate duplicate entries; the ksort function (operating on the decimal numerical value of the IP addresses as keys) seems to take care of this automatically.
Should I have expected this? Or am I just lucky?! Always nervous of the unexpected, even if it's good news!
With thanks.