PHP如何在foreach循环中合并数组

How do i merge all $related_array in the foreach loop into 1 array not multidimesional.

 $get_categories = $wpdb->get_results("SELECT related FROM wp_pato_category_related WHERE slug IN ('$categories')");

                foreach($get_categories as $array) {
                        $related_array = unserialize($array->related);


                }

You can flatten the array using Standard PHP Library (SPL)

So in your code, flatten $related_array with RecursiveArrayIterator

$related_flat = new RecursiveIteratorIterator(new RecursiveArrayIterator($related_array));