I've got a little problem sorting arrays.
I've got an array like this:
- Code: Select all
$arr[0][0] = "Name1";
$arr[0][1] = "80.0.0.1";
$arr[1][0] = "Name2";
$arr[1][1] = "80.0.0.1";
$arr[2][0] = "Name3";
$arr[2][1] = "213.0.0.1";
etc...
and I want the array to become like this:
- Code: Select all
Array
(
[0] => Array
(
[name] => Array
(
[0] => name1
[1] => name2
)
[ip] => 80.0.0.1
)
[1] => Array
(
[name] => Array
(
[0] => name3
)
[ip] => 213.0.0.1
)
)
so all double entries need to become one (like if you've got twice Peter,80.0.0.1 in the array) and all the different names with the same ip need to be ordered like the above array
How to do this? :/ I've tried so many things now, but can't seem to find the right way. I don't really want a double for-loop to sort everything, there must be a smarter way to do this...
anybody can figure out a script to solve my problem?


