简体   繁体   English

如何将数组变量(刀片模板)传递给CodeIgniter视图?

[英]How to pass Array Variable (Blade Template) to CodeIgniter View?

I'm working with https://github.com/cntaoyu/CI-Blade framework and my controller is : 我正在使用https://github.com/cntaoyu/CI-Blade框架,我的控制器是:

class Welcome extends CI_Controller
{
    public function index()
    {
        $data['student'] = array('rollno' => '1','name' => 'Joyy');
        $this->blade->view('welcome_message', $data['student']);
    }
}

VIEW FILE 查看文件

{{$name}} // this prints Joyy

@foreach($student as $users) //student or data, both dont work
    <h2>{{ $users }}</h2>                                                                
@endforeach

You can pass variable in controller and use assignee name of variable in view file. 您可以在控制器中传递变量,并在视图文件中使用变量的受让人名称。 Consider below example 考虑下面的例子

class Welcome extends CI_Controller
    {
        public function index()
        {
            $data['student'] = array('rollno' => '1','name' => 'Joyy');
            $this->blade->view('welcome_message', ['students' => $data['student']]);
        }
    }

VIEW FILE 查看文件

{{$name}} // this prints Joyy

@foreach($students as $student) //student or data, both dont work
    <h2>{{ $student }}</h2>                                                                
@endforeach

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用CodeIgniter中的模板解析器将带有键的数组传递到视图中 - How to pass an array with key into view using Template Parser in CodeIgniter 如何将数组控制器传递给刀片视图? - How to pass array contoller to blade view? 如何在Laravel 5的刀片模板中创建变量以供部分视图使用 - How to create a variable in a blade template in laravel 5 to be used by a partial view 如何在刀片模板的另一个视图中访问变量值? - How to access a variable value in another view in blade template? 如何从一个刀片视图重定向到另一个刀片视图,并将动态生成的变量传递给它? - How to redirect from one blade view to another blade view, and pass dynamically generated variable to it? Laravel - 如何在视图(刀片)中传递值等于输入值的变量? - Laravel - how to pass variable that value is equal to input value in view(blade)? 如何在codeigniter中将变量从视图传递到控制器 - How to pass a variable from view to controller in codeigniter CodeIgniter如何将视图中的变量传递给控制器 - CodeIgniter How to pass a variable from view to the controller PHP Array Foreach()将变量从数据库传递到CodeIgniter模板解析器 - PHP Array Foreach() Pass Variable From Database to CodeIgniter Template Parser 如何通过对象数组查看? MVC ..在Codeigniter中 - how to pass Array of object to view ? MVC ..in Codeigniter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM