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

  • Home
  • SEARCH
  • 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 4021880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:24:22+00:00 2026-05-20T10:24:22+00:00

I need help. I have this function: function getFriendsUploadActivity($user_id, $limit){ $res = $this->exec( SELECT

  • 0

I need help. I have this function:

    function getFriendsUploadActivity($user_id, $limit){
    $res = $this->exec(
        "SELECT bimg.hash,bimg.image_id,bimg.user_id,bimg.time,img_v2.server,img_v2.loc,img_v2.newname,img_v2.name FROM bimg 
        LEFT JOIN img_v2 ON bimg.image_id = img_v2.id 
        WHERE bimg.user_id IN (SELECT subscription FROM subscribes WHERE subscriber = '$user_id') 
        AND img_v2.protected = '0' 
        OR bimg.user_id = '$user_id' 
        ORDER BY bimg.time DESC"
    );
    while($r = mysql_fetch_array($res)){
        $hash[$r['hash']][] = $r;
    }

    $res2 = $this->exec(
        "SELECT * FROM sets WHERE sets.user_id IN (SELECT subscription FROM subscribes WHERE subscriber = '$user_id')  
        OR sets.user_id = '$user_id'  
        ORDER BY sets.time DESC"
    );
    while($r2 = mysql_fetch_array($res2)){
        $hash[$r2['name']][] = $r2;
    }

    return $hash;
}

This function returns array like this:

Array
(
    [5ddf] => Array
        (
            [0] => Array
                (
                    [0] => 5ddf
                    [hash] => 5ddf
                    [1] => 18778
                    [image_id] => 18778
                    [2] => 4
                    [user_id] => 4
                    [3] => 1295556514
                    [time] => 1295556514
                )

        )
    [d6e4] => Array
        (
            [0] => Array
                (
                    [0] => d6e4
                    [hash] => d6e4
                    [1] => 18631
                    [image_id] => 18631
                    [2] => 4
                    [user_id] => 4
                    [3] => 1295556512
                    [time] => 1295556512
                 )
            [1] => Array
                (
                    [0] => d6e4
                    [hash] => d6e4
                    [1] => 18630
                    [image_id] => 18630
                    [2] => 4
                    [user_id] => 4
                    [3] => 1295556510
                    [time] => 1295556510
                 )
        )

    [lorem ipsum] => Array
        (
            [0] => Array
                (
                    [0] => 33
                    [id] => 33
                    [1] => lorem ipsum
                    [name] => lorem ipsum
                    [2] => 42
                    [user_id] => 42
                    [3] => 0
                    [type] => 0
                    [4] => 233324
                    [time] => 1295745642
                )

        )
   [bla bla] => Array
        (
            [0] => Array
                (
                    [0] => 2
                    [id] => 2
                    [1] => bla bla
                    [name] => bla bla
                    [2] => 4
                    [user_id] => 4
                    [3] => 0
                    [type] => 0
                    [4] => 233324
                    [time] => 1295745632
                )

        )

)

Right now the result from $res2 is added at the end of array. I need to sort child arrays by [time] value. So in this way all arrays in my primary array will be sorted by time witch i can get from [time] value.

  • 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-05-20T10:24:23+00:00Added an answer on May 20, 2026 at 10:24 am

    You can do something along these lines:

    function cmp($a,$b) {
       $timea = $a[0]['time'];
       $timeb = $b[0]['time'];
       if ($timea == $timeb) 
           return 0;
       return ($timea < $timeb)? -1:1;
    }
    uasort($hash, 'cmp');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.