Jump to content

Recommended Posts

I have a 1 dimensional array from a database output that I need to have in a multidimensional array ($tasks):

array
0 =>
array
'sr_id' => string '4902367' (length=7)
'description' => string 'GLS Jersey Mikes Installation Checklist' (length=39)
'due_date' => string '2012-01-07 23:24:00' (length=19)
'sr_fe_task_id' => string '220958' (length=6)
1 =>
array
'sr_id' => string '4902367' (length=7)
'description' => string 'Please submit your pictures of the installation area before any work was performed.' (length=83)
'due_date' => string '2012-01-07 23:24:00' (length=19)
'sr_fe_task_id' => string '220959' (length=6)
2 =>
array
'sr_id' => string '4902367' (length=7)
'description' => string 'Please submit your pictures of the installation area after all work was completed.' (length=82)
'due_date' => string '2012-01-07 23:24:00' (length=19)
'sr_fe_task_id' => string '220960' (length=6)
3 =>
array
'sr_id' => string '4903303' (length=7)
'description' => string 'Upload pictures of colored patch cables connected to back of router.' (length=116)
'due_date' => string '2012-01-07 23:31:00' (length=19)
'sr_fe_task_id' => string '220961' (length=6)
4 =>
array
'sr_id' => string '4899664' (length=7)
'description' => string 'Please upload all pictures taken on site.' (length=41)
'due_date' => string '2012-01-17 17:33:00' (length=19)
'sr_fe_task_id' => string '222839' (length=6)

 

Each sr_id may have more than one task under it and each task has a due_date and description under it, but I'm having trouble getting the descriptions and due_dates under each task:

['sr_id'] =>4902367
        ['sr_fe_task_id'] => 220958
                   ['description']=> "GLS Jersey Mikes Installation Checklist"
                   ['due_date']=> '2011-12-08 17:50:00'
         ['sr_fe_task_id'] => 220959
                   ['description']=> "Pleease submit your pictures of the installation area."
                   ['due_date']=> '2012-01-07 23:24:00'
['sr_id'] =>4903303
         ['sr_fe_task_id'] => 220961
                   ['description']=> "Upload pictures of colored patch cables connected to back of router."
                   ['due_date']=> '2012-01-07 23:31:00'

 

I've got it to where each sr_id is listed along with all the tasks underneath of them, but can't get it to where each task has the description and due date under it:

for ($i=0; $i<COUNT($tasks); $i++){
$task_list[$tasks[$i]['sr_id']]['task_id'][$tasks[$i]['sr_fe_task_id']] =$tasks[$i]['sr_fe_task_id'];

foreach ($task_list[$tasks[$i]['sr_id']]['task_id'] as $v){
 $task_list[$tasks[$i]['sr_id']]['task_id'][$v][$tasks[$i]['due_date']];
}
}

Solved:

 

 

foreach ($tasks as $task) {
$task_list[$task['sr_id']]['task_id'][$task['sr_fe_task_id']] = array();
$task_list[$task['sr_id']]['task_id'][$task['sr_fe_task_id']]['due_date'] = $task['due_date'];
$task_list[$task['sr_id']]['task_id'][$task['sr_fe_task_id']]['description'] = $task['description'];
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.