Advertisement

04.29.2008 at 09:27AM PDT, ID: 23362608
[x]
Attachment Details

Sorting a simple php array

Asked by yodercm in PHP Scripting Language

Tags: php

For you php experts who know arrays and sorting really well, I could use some suggestions on this.

I need to have an array containing the following data:
MemberNumber
LastName
FirstName
Role
Date (mysql format for sorting)
FormattedDate (for printing)

Not all members will have all roles or dates and vice versa.

From this, I need to be able to produce another array as a matrix that I can print from containing all the members, roles and dates that appear in the first array.  The matrix must be sortable by any of LastName, Date, Role, and must contain    in all the positions that don't have a value from the first array.  I have to maintain the relationship among the elements in the array.

In other words, I need to produce a matrix that can be printed with any of the LastName, FormattedDate, or Role as the column header, row header, and value.  Six possible print cases -- for example, case 1 would be FirstName/LastName across the top, FormattedDate down the left, and Role in the matrix cells, and the other 5 cases similar with different choices.  In each case, I need to sort by the underlying value of the column header and row header (that is sorted by Date, not FormattedDate, and by LastName).

What is the best way to set up this array and what sort function(s) will allow me to sort it by row and column selection based on a php variable?Start Free Trial
[+][-]04.29.2008 at 09:35AM PDT, ID: 21463812

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.30.2008 at 07:09PM PDT, ID: 21476076

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 01:46AM PDT, ID: 21485295

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 06:28AM PDT, ID: 21486423

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 06:31AM PDT, ID: 21486452

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 07:13AM PDT, ID: 21486806

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: php
Sign Up Now!
Solution Provided By: Roonaan
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628