Re: problem with join(array, "")
| From: | Dave Hull | Date: | Wed, 31 May 2000 15:34:17 +0000 |
| Subject: | Re: problem with join(array, "") | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-731@lists.php.net to get a copy of this message | ||
Thanks for your help, I had a more experienced programmer here on campus
look at it. She found that the documentation states that there's no
difference between scalar and associative arrays in php. Hence, array[4]
does not necessarily come after array[3], it all depends on the order in
which the elements are assigned, not the subscript.
So, ksort($array) does the job of sorting the array based on the key. This
leaves me with:
$octet[4] = strtok($remote_ip, ".");
for ($i = 3; $i >= 1; $i--) {
$octet[$i] = strtok(".");
}
ksort($octet);
$revip = join("", $octet);
echo $revip;
Which does exactly what I want it to do, removes the dots from and reverses
an ip address.
Thanks again.
dp