Concatenates two array into one

PHOTO EMBED

Fri Feb 11 2022 12:06:32 GMT+0000 (Coordinated Universal Time)

Saved by @arnoa69 #php

    /* 
    ----------------------------------------------------------------------------
                                plan_solutions 
    ----------------------------------------------------------------------------
    */
    public function getPlanCategoryAndSolutions() {
        $categories = $this->builderPlanCategories->orderBy('weight', 'ASC')
          ->getWhere(['title !=' => 'gemeinsam genutzte Sicherheitseinrichtungen'])
          ->getResultArray();
        $solutions = $this->builderPlanSolutions->get()->getResultArray();

        foreach($categories as $key => $category) {
            for($i = 0; $i < count($solutions); $i++) {
                if($category['pc_id'] == $solutions[$i]['category_id']) {
                    $categories[$key]['solutions'][] = $solutions[$i];
                }
            }
        }
        return $categories;
    }
content_copyCOPY

I could have done it also with two foreach(), but it did not work at first. I had first to figur out $categories[$key]['solutions'][] to add all solutions belonging to a category