Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

sorting arrays

General discussions related to php

Moderators: macek, egami, gesf

sorting arrays

Postby *JaH* » Mon Apr 07, 2003 1:51 am

Hi guys,

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? :)
*JaH*
New php-forum User
New php-forum User
 
Posts: 80
Joined: Fri Jan 31, 2003 4:18 pm

Postby *JaH* » Tue Apr 08, 2003 2:53 pm

hah, too hard for you guyz eh?
*JaH*
New php-forum User
New php-forum User
 
Posts: 80
Joined: Fri Jan 31, 2003 4:18 pm


Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron