Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8237561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:30:40+00:00 2026-06-07T19:30:40+00:00

I know this has been posted before, but I couldnt get it to work

  • 0

I know this has been posted before, but I couldnt get it to work for me :s not sure why! But anywhooo My array $servers looks like this

Array
(
    [0] => Array
        (
            [0] => Dell PowerEdge R210 II
            [1] => 8
            [2] => Array
                (
                    [0] => 8
                    [1] => Sock
                    [2] => Price
                    [3] => ImageURL
                    [4] => CPU
                    [5] => Memory
                    [6] => HDD
                    [7] => Bandwidth
                    [8] => OS
                    [9] => Upgrades
                    [10] => OrderLink
                )

        )

    [1] => Array
        (
            [0] => Dell PowerEdge R210 II 2
            [1] => 2
            [2] => Array
                (
                    [0] => 2
                    [1] => Sock
                    [2] => Price
                    [3] => ImageURL
                    [4] => CPU
                    [5] => Memory
                    [6] => HDD
                    [7] => Bandwidth
                    [8] => OS
                    [9] => Upgrades
                    [10] => OrderLink
                )

        )

    [2] => Array
        (
            [0] => Dell PowerEdge R210 II 3
            [1] => 3
            [2] => Array
                (
                    [0] => 3
                    [1] => Sock
                    [2] => Price
                    [3] => ImageURL
                    [4] => CPU
                    [5] => Memory
                    [6] => HDD
                    [7] => Bandwidth
                    [8] => OS
                    [9] => Upgrades
                    [10] => OrderLink
                )

        )

    [3] => Array
        (
            [0] => Dell PowerEdge R210 II 4
            [1] => 4
            [2] => Array
                (
                    [0] => 4
                    [1] => Sock
                    [2] => Price
                    [3] => ImageURL
                    [4] => CPU
                    [5] => Memory
                    [6] => HDD
                    [7] => Bandwidth
                    [8] => OS
                    [9] => Upgrades
                    [10] => OrderLink
                )

        )

    [4] => Array
        (
            [0] => Dell PowerEdge R210 II 5
            [1] => 5
            [2] => Array
                (
                    [0] => 5
                    [1] => Sock
                    [2] => Price
                    [3] => ImageURL
                    [4] => CPU
                    [5] => Memory
                    [6] => HDD
                    [7] => Bandwidth
                    [8] => OS
                    [9] => Upgrades
                    [10] => OrderLink
                )

        )

    [5] => Array
        (
            [0] => Dell PowerEdge R210 II 6
            [1] => 6
            [2] => Array
                (
                    [0] => 6
                    [1] => Sock
                    [2] => Price
                    [3] => ImageURL
                    [4] => CPU
                    [5] => Memory
                    [6] => HDD
                    [7] => Bandwidth
                    [8] => OS
                    [9] => Upgrades
                    [10] => OrderLink
                )

        )

)

I’d like to have the array re-arranged and put back into $servers but in order of $servers[x][1]

So where the singular number is (1st object is 8) I’d like it to sort it with the smallest number 1st, moving to the largest!

Many thanks

ps i tried this

<?php
function cmp($a, $b)
{
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? -1 : 1;
}

$a = array(3, 2, 5, 6, 1);

usort($servers, "cmp");
?>

but it didnt seem to work!

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:30:41+00:00Added an answer on June 7, 2026 at 7:30 pm

    Your cmp is wrong. $a and $b are arrays like

    Array
        (
            [0] => Dell PowerEdge R210 II 6
            [1] => 6
            [2] => Array
                (
                    [0] => 6
                    [1] => Sock
                    [2] => Price
                    [3] => ImageURL
                    [4] => CPU
                    [5] => Memory
                    [6] => HDD
                    [7] => Bandwidth
                    [8] => OS
                    [9] => Upgrades
                    [10] => OrderLink
                )
    
        )
    

    and you must compare $a[1] with $b[1]:

    function cmp($a, $b) {
        return $a[1] - $b[1];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been posted before... but I haven't found any answer
I know this has been asked before ( Get Absolute Position of element within
I know this has been asked different ways several times, but I'm just not
I know this has been asked many times before, but i still can't seem
I know this has been asked before but all the answers I found didn't
I know this question has been possed before, but the explanation was a little
I know this question has been posted here before, and I've trawled through as
I know this has been posted a few times but I am starting to
I know this has been asked before but I have looked at every answer
I know this question has been posted on this forum before: How do you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.