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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:36:12+00:00 2026-05-17T01:36:12+00:00

I’m trying to figure out how to sort a 2d array into a 3d

  • 0

I’m trying to figure out how to sort a 2d array into a 3d array in PHP. The array contains tasks from users in a management tree and is currently arranged like so:

Array ( [0] => Array ( [Title] => Test Task [Author] => 5 [DateIn] => 2010-09-15 [Deadline] => 2010-09-30 [Position] => 1 [Description] => This is a test task [Assignee] => 3 ) [1] => Array ( [Title] => Test Task [Author] => 5 [DateIn] => 2010-09-15 [Deadline] => 2010-09-29 [Position] => 1 [Description] => Blah blah [Assignee] => 3 ) ) 

I want to sort it so that it’s a 3d array where each 2nd level array contains all of the tasks assigned to one user. Is there an easy way to do this? The closest thing I found was array_multsort, but that doesn’t quite do what I want.

*Edits
This is basically a task manager app for the company I currently work for. Managers need to be able to see the tasks that have been assigned to their employees. I currently have employees and supervisors organized into a tree, so they need to see everything in their branch.

Right now, the function I’ve written returns the tasks for employees of each “manager” sorted in no particular order. To reduce clutter, I need to be able to only display one “employee’s” tasks at a time. Currently this is not possible, as the structure of the array is such that it simply contains a list of all the tasks where the author is marked as the current user.

In short, I would like to sort these tasks into a 3 dimensional array, where each 2nd level array contains the tasks belonging to one “employee” belonging to the current user.

  • 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-17T01:36:13+00:00Added an answer on May 17, 2026 at 1:36 am

    I don’t quite understand what you’re getting at, but if you want to produce a new array which lists tasks by assignee, then you can use the following.

    foreach ( $old as $task )
      $new[$task['Assignee']][] = $task;
    

    This will give you an array where the keys are the assignee IDs and the sub arrays are the tasks assigned to them.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but

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.