Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 想要在codeigniter中创建一个多维数组,如下所示_Php_Codeigniter 3 - Fatal编程技术网

Php 想要在codeigniter中创建一个多维数组,如下所示

Php 想要在codeigniter中创建一个多维数组,如下所示,php,codeigniter-3,Php,Codeigniter 3,我想要这样的数组格式 Array ( [id] => 34 [restaurant_name] => Chow Pow [state] => Odisha [city] => Cuttack [address] => Daraghabazar, Kumbhar Sahi [logo] => c4ca4238a0b923820dcc509a6f75849b

我想要这样的数组格式

  Array
    (
        [id] => 34
        [restaurant_name] => Chow Pow
        [state] => Odisha
        [city] => Cuttack
        [address] => Daraghabazar, Kumbhar Sahi
        [logo] => c4ca4238a0b923820dcc509a6f75849b.jpg
        [open_time] => 11:00
        [close_time] => 22:00
        [rating] => 3.5
        [count_rating] => 4
        [restaurant_email] => soumya@oricubetechnology.com
        [service_type] => both
        [status] => approved
        [gst] => 5.6
        [telephone_no] => 0674-23823456
        [postcode] => 2000
        [suburb] => SYDNEY
        [abn] => 12345678901
        [restaurant_id] => 1
        [servicearea_postcode] => 753010
        [servicearea_suburb] => 753010 - Cuttack
        [delivery_time] => 00:45
        [delivery_fee] => 100
        [min_order] => 1000
        [min_order_free] => 500
        [cuisines] => Array
            (
                [0] => Array
                    (
                        [id] => 60
                        [restaurant_id] => 1
                        [dealsin] => Chinese
                    )

            )

        [coupons] => Array
            (
                [0] => Array
                    (
                        [id] => 1
                        [restaurant_id] => 1
                        [coupon_code] => PURBA100
                        [coupon_discount] => 20
                        [no_of_usage] => 5
                    )

            )

        [categories] => Array
            (
                [menus] => Array
                    (
                        [0] => Array
                            (
                                [id] => 11
                                [restaurant_id] => 1
                                [cat_name] => Baker's Treat - Breaddd
                                [itemname] => Elaichi Bread Roll
                                [food] => nonveg
                                [food_type] => 
                                [price] => 320.00
                                [restaurant_price] => 20.00
                                [stock_qty] => 20
                                [stock_out_qty] => 19
                                [commission] => 300.00
                                [item_img] => 6512bd43d9caa6e02c990b0a82652dca.jpg
                                [created_date] => 0000-00-00
                            )

                        [1] => Array
                            (
                                [id] => 15
                                [restaurant_id] => 1
                                [cat_name] => Baker's Treat - Breaddd
                                [itemname] => Bread Crumbsggggg
                                [food] => nonveg
                                [food_type] => 
                                [price] => 0.00
                                [restaurant_price] => 65.00
                                [stock_qty] => 0
                                [stock_out_qty] => 0
                                [commission] => 0.00
                                [item_img] => 9bf31c7ff062936a96d3c8bd1f8f2ff3.jpg
                                [created_date] => 0000-00-00
                            )

                        [2] => Array
                            (
                                [id] => 23
                                [restaurant_id] => 1
                                [cat_name] => Baker's Treat - Breaddd
                                [itemname] => Chiken Biriyani
                                [food] => egg
                                [food_type] => 
                                [price] => 0.00
                                [restaurant_price] => 300.00
                                [stock_qty] => 0
                                [stock_out_qty] => 0
                                [commission] => 0.00
                                [item_img] => 37693cfc748049e45d87b8c7d8b9aacd.jpg
                                [created_date] => 0000-00-00
                            )

                        [3] => Array
                            (
                                [id] => 24
                                [restaurant_id] => 1
                                [cat_name] => Baker's Treat - Breaddd
                                [itemname] => Chiken Biriyani1
                                [food] => veg
                                [food_type] => 
                                [price] => 0.00
                                [restaurant_price] => 89.00
                                [stock_qty] => 0
                                [stock_out_qty] => 0
                                [commission] => 0.00
                                [item_img] => 1ff1de774005f8da13f42943881c655f.jpg
                                [created_date] => 0000-00-00
                            )

                        [4] => Array
                            (
                                [id] => 32
                                [restaurant_id] => 1
                                [cat_name] => Baker's Treat - Breaddd
                                [itemname] => Vege Pie
                                [food] => veg
                                [food_type] => 
                                [price] => 45.00
                                [restaurant_price] => 45.00
                                [stock_qty] => 5
                                [stock_out_qty] => 5
                                [commission] => 0.00
                                [item_img] => 
                                [created_date] => 0000-00-00
                            )

                        [5] => Array
                            (
                                [id] => 34
                                [restaurant_id] => 1
                                [cat_name] => Baker's Treat - Breaddd
                                [itemname] => Finger bun
                                [food] => veg
                                [food_type] => 
                                [price] => 2.00
                                [restaurant_price] => 2.00
                                [stock_qty] => 1
                                [stock_out_qty] => 1
                                [commission] => 0.00
                                [item_img] => 
                                [created_date] => 0000-00-00
                            )

                    )

            )

    )
我已经为此编写了代码,但它只会显示最后一个类别菜单。我认为,如果我将在category循环中连接数组,那么它将解决我的问题。但我无法做到这一点。下面是控制器的代码

//To show the result of clicked restaurant from searched restaurant
    public function restaurant_details($restaurant_id)
    {
        $search_suburb = $this->session->userdata('search_suburb');
        $get_restaurant_details = $this->searchRestaurantModel->get_restaurant_details($restaurant_id, $search_suburb);

        $restaurant_details = array();
        foreach($get_restaurant_details as $res_details)
        {
            $get_cus = $this->searchRestaurantModel->get_restaurant_cuisines($res_details['restaurant_id']);
            $get_cup = $this->searchRestaurantModel->get_restaurant_coupons($res_details['restaurant_id']);
            $get_category = $this->searchRestaurantModel->get_restaurant_categories($res_details['restaurant_id']);
            $restaurant_id = $res_details['restaurant_id'];

            $res_details['cuisines'] = $get_cus;
            $res_details['coupons'] = $get_cup;
            $res_details['all_categories'] = $get_category;
            //Category Items name
            $restaurant_menus = array();
            foreach($get_category as $res_category)
            {
                //echo $res_category['cat_name'];
                $get_menu = $this->searchRestaurantModel->get_restaurant_menus($res_category['cat_name'], $res_details['restaurant_id']);

                $res_details['categories']['menus'] = $get_menu;
                //echo "<pre>";
                //print_r($res_details);
                //die();
            }
            array_push($restaurant_details, $res_details);

        }
        echo "<pre>";
        print_r($restaurant_details);
        die();

        //Breadcrumb
        $this->breadcrumbs->push('Home', '/');
        $this->breadcrumbs->push('Search Results', 'restaurants/restaurant_search');        
        $this->breadcrumbs->push($res_details['restaurant_name'], '#');


        $data['title'] = $res_details['restaurant_name']. 'Home Delivery in '.$res_details['servicearea_suburb'];
        $data['restaurant_details'] = $restaurant_details;
        $this->load->view('header', $data);
        $this->load->view('restaurants_details');
        $this->load->view('footer');
    }
//显示从搜索的餐厅中单击的餐厅的结果
公共功能餐厅详细信息(餐厅id)
{
$search\u郊区=$this->session->userdata('search\u郊区');
$get\u restaurant\u details=$this->searchRestaurantModel->get\u restaurant\u details($restaurant\u id,$search\u);
$restaurant_details=array();
foreach($get_餐厅_详情为$res_详情)
{
$get\u cus=$this->searchRestaurantModel->get\u restaurant\u cusines($res\u details['restaurant\u id');
$get_cup=$this->searchRestaurantModel->get_restaurant_优惠券($res_details['restaurant_id']);
$get_category=$this->searchRestaurantModel->get_restaurant_categories($res_details['restaurant_id']);
$restaurant_id=$res_details['restaurant_id'];
$res_details['cuisines]=$get_cus;
$res_details['coups]=$get_cup;
$res_details['all_categories]=$get_categories;
//类别项目名称
$restaurant_menus=array();
foreach($get\u category作为$res\u category)
{
//echo$res_类别['cat_name'];
$res_details['categories']['menus'] = $get_menu; //---> you miss to add array
$get_menu=$this->searchRestaurantModel->get_restaurant_menu($resu category['cat_name'],$resu details['restaurant_id']); $res_详细信息['categories']['menu']=$get_menu; //回声“;
$res_details['categories']['menus'] = $get_menu; //---> you miss to add array
//打印($res\u详细信息); //模具(); } 数组推送($restaurant\u details,$res\u details); } 回声“; 打印(餐厅详细信息); 模具(); //面包屑 $this->breadcrumbs->push('Home','/'); $this->breadcrumbs->push('搜索结果','餐厅/餐厅搜索'); $this->breadcrumbs->push($res_details['restaurant_name','); $data['title']=$res_详细信息['restaurant_name'].'Home Delivery in.$res_详细信息['servicearea_Suburban']; $data['restaurant_details']=$restaurant_details; $this->load->view('header',$data); $this->load->view('restaurants_details'); $this->load->view('footer'); }
更换代码

有以下几点

希望这对你有用。如果还有其他事情,请告诉我们