SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Location
    London
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP multisort problem [SOLVED]

    Hi guys,

    I have an nested multi-dimensional array like this:

    Code:
    Array
            [0] Array
                         [0]=>42[id]=>42
                         [1]=>Audience[groupname]=>Audience
                         [2]=>0[is_active]=>0
    
            [1] Array, etc, etc...
    To sort it I used the statement:

    PHP Code:

    array_multisort
    ($input[groupname], SORT_ASCSORT_STRING); 
    I originally tried...

    PHP Code:

    array_multisort
    ($input[1], SORT_ASCSORT_STRING); 
    ...but to no avail...

    I want to sort by groupname: Anybody know what I'm doing wrong or how to fix it?

    Any help would really be appreciated...

    Thanks in advance...
    Last edited by jmsherry; Jul 20, 2009 at 06:34. Reason: solved

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Location
    London
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://firsttube.com/read/sorting-a-...rray-with-php/

    Has the solution...

    Part 2 of my problem now is that I'm trying to array_combine with this multidimensional array and give the key values to only the first level array...

    Anybody know how to do that?

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Location
    London
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry...had applied padding to wrong thing...server had errors suppressed...

    array_combine works fine when the elements are equal...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •