2014-03-26 58 views
0

我想显示在表输入使用类型为stdClass的对象为数组,但我的代码生成以下错误:不能在笨

Fatal error: Cannot use object of type stdClass as array in line 36 

这是我的看法:

<tbody> 
           <?php 
            $no=1; 
            if ($berita){ 
            foreach ($berita as $dt) { 
             echo " 
              <tr> 
               <td>$dt[id_berita]</td> (line 36) 
               <td>$dt[tanggal]</td> 
               <td>$dt[judul_berita]</td> 
               <td>$dt[content]</td> 
               <td><a class='ui tiny blue edit button' href='".base_url()."index.php/admin/berita/edit/$dt[id_berita]'><i class='edit icon'></i></a> 
               <a class='ui tiny blue edit button' href='".base_url()."index.php/admin/berita/delete/$dt[id_berita]'><i class='trash icon'></i></a></td> 

              </tr> 
             "; 
             $no++; 
            } 
            } 
           ?> 

          </tbody> 

是什么我的代码问题?

回答

2

如果$ dt为对象,比你可以将它下面

$dt->id_berita 
$dt->tanggal 
+0

感谢其解决 – user3459150