[英]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.