Jump to content

Sorting Arrays


cheechm

Recommended Posts

Hi,

How would I sort these two arrays against each other?

 

Array
(
    [domain] => localhost
    [postcode] => SW10
    [name] => Point
    [company_name] => Point
    [shipping_username] => Nick
    [api_key] => ********
    [address] => London
    [subtitle] => Cool Test
    [phone] => 0777777
    [limit] => 10
    [delivery] => 1.50
    [email_confirm] => 1
    [online] => 1
    [seed] => 0dAfghRqSTgx
    [install_path] => /server/lhs/
)
Array
(
    [name] => 1
    [online] => 12
    [postcode] => 8
    [phone] => 6
    [address] => 7
    [delivery] => 11
    [subtitle] => 2
    [email_confirm] => 9
    [domain] => 3
    [install_path] => 4
    [seed] => 0
    [limit] => 10
    [api_key] => 14
    [shipping_username] => 13
    [company_name] => 5
)

 

You'll see in the second array for instance that [name] => 1 and [subtitle] => 2.. How in the first array would I order it so that is went:

    [name] => Point

    [subtitle] => Cool Test

...etc?

 

I tried array_multisort() but I don't think it is the right one? If it is I couldn't get it to work.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/125061-sorting-arrays/
Share on other sites

If I had an array like this:

 

Array
(
    [subtitle] => Array
        (
            [value] => Cool Test
            [name] => Subtitle
            [order] => 2
            [section] => 1
            [type] => 0
        )

    [domain] => Array
        (
            [value] => localhost
            [name] => Domain Name 
            [order] => 3
            [section] => 0
            [type] => 0
        )
)

 

How would I sort the array by order?

 

Link to comment
https://forums.phpfreaks.com/topic/125061-sorting-arrays/#findComment-646990
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.