<tfoot id='8aAPo'></tfoot>

<small id='8aAPo'></small><noframes id='8aAPo'>

  • <i id='8aAPo'><tr id='8aAPo'><dt id='8aAPo'><q id='8aAPo'><span id='8aAPo'><b id='8aAPo'><form id='8aAPo'><ins id='8aAPo'></ins><ul id='8aAPo'></ul><sub id='8aAPo'></sub></form><legend id='8aAPo'></legend><bdo id='8aAPo'><pre id='8aAPo'><center id='8aAPo'></center></pre></bdo></b><th id='8aAPo'></th></span></q></dt></tr></i><div id='8aAPo'><tfoot id='8aAPo'></tfoot><dl id='8aAPo'><fieldset id='8aAPo'></fieldset></dl></div>

      • <bdo id='8aAPo'></bdo><ul id='8aAPo'></ul>
        <legend id='8aAPo'><style id='8aAPo'><dir id='8aAPo'><q id='8aAPo'></q></dir></style></legend>

      1. codeigniter:将数组从控制器传递到视图

        时间:2023-10-02
        • <legend id='NdyJi'><style id='NdyJi'><dir id='NdyJi'><q id='NdyJi'></q></dir></style></legend>
          1. <small id='NdyJi'></small><noframes id='NdyJi'>

                <tbody id='NdyJi'></tbody>

                • <bdo id='NdyJi'></bdo><ul id='NdyJi'></ul>

                  <i id='NdyJi'><tr id='NdyJi'><dt id='NdyJi'><q id='NdyJi'><span id='NdyJi'><b id='NdyJi'><form id='NdyJi'><ins id='NdyJi'></ins><ul id='NdyJi'></ul><sub id='NdyJi'></sub></form><legend id='NdyJi'></legend><bdo id='NdyJi'><pre id='NdyJi'><center id='NdyJi'></center></pre></bdo></b><th id='NdyJi'></th></span></q></dt></tr></i><div id='NdyJi'><tfoot id='NdyJi'></tfoot><dl id='NdyJi'><fieldset id='NdyJi'></fieldset></dl></div>
                • <tfoot id='NdyJi'></tfoot>
                  本文介绍了codeigniter:将数组从控制器传递到视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有 CodeIgniter 问题.如何将数组从控制器传递到视图?这是我的代码不起作用:

                  控制器:

                  $data_part13['header3_item'][] = array('title' => 'first image 1' , 'img' => 'https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQoshslL3aMNzG50708domqPSA4ouPjk_wA7jCpVRUH3k8zVdn9');$this->load->view('part_1_3', $data_part13);

                  并查看:

                  <div id="header3-inner"><?php如果(isset($header3_item)){foreach ($header3_item 作为 $key) {?><div class="header3-item"><img alt="<?php echo($key->title); ?>"src="<?php echo($key->img); ?>"/>

                  <?php}}?>

                  解决方案

                  你做对了(有点).您将数组传递给视图,但您的问题是您在视图中使用了一个对象.你应该做这样的事情:

                  $data_part13['header3_item'][] = (object) array('title' => 'first image 1' , 'img' => 'https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQoshslL3aMNzG50708domqPSA4ouPjk_wA7jCpVRUH3k8zVdn9');$this->load->view('part_1_3', $data_part13);

                  视图部分可以保持不变.

                  I have CodeIgniter question. How can I pass an array from controller to view? Here is my code that doesn't work:

                  controller:

                  $data_part13['header3_item'][] = array('title' => 'first image 1' , 'img' => 'https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQoshslL3aMNzG50708domqPSA4ouPjk_wA7jCpVRUH3k8zVdn9' );
                  
                  $this->load->view('part_1_3', $data_part13);
                  

                  and view:

                  <div id="header3">
                      <div id="header3-inner">
                          <?php
                          if (isset($header3_item)){
                              foreach ($header3_item as $key) {
                          ?>
                                  <div class="header3-item">
                                      <img alt="<?php echo($key->title); ?>" src="<?php echo($key->img); ?>"/>
                                  </div>
                          <?php
                              }
                          }
                          ?>
                      </div>
                  </div>
                  

                  解决方案

                  You did it correctly (kinda). You passed an array to the view, but your problem was that you were using an object in the view. You should have instead done something like this:

                  $data_part13['header3_item'][] = (object) array('title' => 'first image 1' , 'img' => 'https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQoshslL3aMNzG50708domqPSA4ouPjk_wA7jCpVRUH3k8zVdn9' );
                  
                  $this->load->view('part_1_3', $data_part13);
                  

                  The view part can stay the same.

                  这篇关于codeigniter:将数组从控制器传递到视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在不使用ajax刷新的情况下重新加载数据表 下一篇:Laravel 中 View Composer 和 Creator 的区别?

                  相关文章

                  最新文章

                    <tfoot id='iJfxF'></tfoot>
                      <bdo id='iJfxF'></bdo><ul id='iJfxF'></ul>

                      <i id='iJfxF'><tr id='iJfxF'><dt id='iJfxF'><q id='iJfxF'><span id='iJfxF'><b id='iJfxF'><form id='iJfxF'><ins id='iJfxF'></ins><ul id='iJfxF'></ul><sub id='iJfxF'></sub></form><legend id='iJfxF'></legend><bdo id='iJfxF'><pre id='iJfxF'><center id='iJfxF'></center></pre></bdo></b><th id='iJfxF'></th></span></q></dt></tr></i><div id='iJfxF'><tfoot id='iJfxF'></tfoot><dl id='iJfxF'><fieldset id='iJfxF'></fieldset></dl></div>
                    1. <small id='iJfxF'></small><noframes id='iJfxF'>

                    2. <legend id='iJfxF'><style id='iJfxF'><dir id='iJfxF'><q id='iJfxF'></q></dir></style></legend>