0

I have the following array containing a master record of training courses held on a system (select_group just identifies related course groups):

Array
(
    [DE00041-1] => Array
        (
            [select_group] => 1
        )
)

The training course ids are then queried against a table containing only running courses whilst also grabbing extra information.

As one training course may run more than once per year they have a running_id which gives the following:

Array
(
    [DE00041-1] => Array
        (
            [title] => xxx
            [405] => Array
                (
                    [start_quarter] => 1
                    [end_quarter] => 1
                )
        )
)

What I then need to do is add the original array select_group data into the newly created array.

The end result should be:

Array
(
    [DE00041-1] => Array
        (
            [title] => xxx
            [select_group] => 1
            [405] => Array
                (
                    [start_quarter] => 1
                    [end_quarter] => 1
                )
        )
)

I have looked over other SO / Google answers but couldn't find what I was looking for.

There may be 1-20 training courses listed, each one running once to four times per year.

0

2 Answers 2

3
foreach($yourArray as $key => $value){
   $yourArray[$key]['select_group'] = $select_group_array[$key]['select_group'];
}
Sign up to request clarification or add additional context in comments.

1 Comment

Perfecto, easy as that! Thanks :)
0

Another variant:

$result = array_merge_recursive($arr1, $arr2);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.