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 8777161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:13:14+00:00 2026-06-13T19:13:14+00:00

I am storing array in the following way $pos[$k] = $total[$k]. / .$posts_ids[$k]. /

  • 0

I am storing array in the following way

$pos[$k] = $total[$k]." / ".$posts_ids[$k]." / ".$time[$k];

I am using following way to extract the value from the pos array.

$a = $b = array();
foreach ($pos as $key => $value){
  list($a[$key], $b[$key], $t[$key]) = explode('/', $value);
  array_multisort($a, SORT_DESC, SORT_NUMERIC, $b ,$t);
}

But i am not able to extract the value of the variable $t as well as not able to sort it without change there position of array.

  • 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-13T19:13:14+00:00Added an answer on June 13, 2026 at 7:13 pm

    You haven’t defined t as an array in your code, which shouldn’t be a problem unless you have no values (but, in that case, you would get a warning).

    As for multisort, the correct syntax would be

    array_multisort($a, $b, $t, SORT_NUMERIC, SORT_DESC);
    

    but it’s not very clear what you want to do, and it might be more convenient to organize differently the parsing of values (e.g. in a multidimensional array instead of multiple arrays, or use a custom sort function).

    <?php
    
            $a = array();
            $b = array();
            $t = array();
    
            $values = array("5/7/12","1/9/3");
    
            foreach($values as $key => $value)
            {
                    list($a[$key], $b[$key], $t[$key]) = explode('/', $value);
            }
            array_multisort($a, $b, $t, SORT_NUMERIC, SORT_DESC);
    
            print_r($a);
            print_r($b);
            print_r($t);
    ?>
    

    as well as not able to sort it without change there position of array.

    That is by design. array_multisort sorts on the first array you pass, which is $a. The corresponding elements in the other arrays will be sorting according to the position of the items in $a.

    For example if the first element of $a is the smallest, it will be placed last in SORT_DESC. But since the first element of $a is last, the last element of $t will also be put last within $t, whatever its value.

    If you want $t to “rule” the sort, you must put it first.

    If you want all three arrays to be independently sorted, you must not use array_multisort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following is the script for matching regex and storing value in array: sub b1
I am storing a jagged array of numbers in approximately the following way... Dim
I am trying to allocate a dynamic string array in the following way and
How do I convert a list of String into an array ? The following
I am converting images to byte array and storing in a text file using
There is array (in JavaScript) of items written in the following way: var arr
I have the following code in javascript I am storing a php array in
A String array can be declared and initialized in the following way: String[] str
Is there an easier way to achieve the following? var obj = from row
I'm using Jquery Airport in the following way: $('#basketTotal').airport([s]); $('#basketTotal').html(s); Here's the Airport function:

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.