'how to merge them into one array in laravel

    $category = Category::with('products')->where('seller_id','=',$request->
     user('seller')->id)->get();
    
    foreach($category as $index=>$opt){
       
        foreach($opt->products as $key => $value)
        {
            print_r( array_column([$key => $value],'id'));
        }
    }

Array ( [0] => 33 ) Array ( [0] => 32 ) Array ( [0] => 36 ) Array ( [0] => 34 ) Array ( [0] => 35 )

i want this as my output

Array ( [0] => 33 ,[0] => 32 ,[0] => 36 , [0] => 34 , [0] => 35 )



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source