Missing array data in codeignitor php : i have menu which get data from database
here is my code 

    <nav id="mysidebarmenu" class="amazonmenu">
                        <ul>
                        <?php
                            //Get Category array
    						$categories = json_decode($this->db->get_where('ui_settings',array('type' => 'home_category'))->row()->value);
    						
                            foreach($categories as $row){
                        ?>
                        <li>
    									<a href="javascript:void(0);">
                                        	<?php
                                            	echo $this->crud_model->get_type_name_by_id('category',$row,'category_name');
    										?>
                                        </a>
                            <div>
                            <div class="col-md-12">
                                <?php
    							//Get Sub Category array
                                    $subs = $this->db->get_where('sub_category',array('category'=>$row['category_id']))->result_array();
    								
                                    foreach($subs as $row1){
                                        $this->db->limit(4);
                                        $this->db->order_by('product_id','desc');
                                        $products = $this->db->get_where('product',array('sub_category'=>$row1['sub_category_id'],'status' =>'ok'))->result_array();
                                ?>
                                    <div class="col-md-12"><h3 class="text-center" style="background:#EAEAEA;"><?php echo $row1['sub_category_name']; ?></h3></div>
                                    <?php
                                        foreach($products as $row2){
                                            if($this->crud_model->is_publishable($row2['product_id'])){
                                    ?>
                                        <div class="col-md-3">
                                            <div class="menu_box">
                                                <div class="img_menu_box" style="background:url('<?php echo $this->crud_model->file_view('product',$row2['product_id'],'','','no','src','multi','one') ?>') no-repeat center center; background-size: 100% auto;">
                                                </div>
                                            
                                            <a href="<?php echo $this->crud_model->product_link($row2['product_id']); ?>">
                                                <?php echo $row2['title']; ?>
                                            </a>
                                           
                                            </div>
                                        </div>
                                    <?php
                                            }
                                        }
                                    ?>
                                <?php
                                    }
                                ?>
                            </div>
                            </div>
                        </li>
                         
                        <?php
                            }
                        ?>
                       
                       
                        </ul>
                        </nav>

**here are results i am getting**<br>
> print_r($categories);<br>
> result = Array ( [0] => 5 [1] => 31 )<br>
> print_r($subs);<br>
> 1- result for Array [0] => 5 = ( [0] => Array ( [sub_category_id] => 18 [sub_category_name] => A [category] => 5 ) [1]
> => Array ( [sub_category_id] => 19 [sub_category_name] => B [category] => 5 ))<br>
>2- result for Array [1] => 31 = Array ( )

the problem is in second array result coming empty

