result_array返回值但在codeigniter中不返回$ key,如果我在視圖中手動添加數據數組,它返回$ key,爲什麼它不會回顯$關鍵。
型號::
<?php
class Admin_user extends CI_Model
{
public function list_rows()
{
$query = array();
$query = $this->db->get('content');
return $query->result_array();
}
}
查看::
<?php
foreach ($get_all_content as $key => $values)
{
$title = $values['title'];
echo "<th>" . $key . "</th>";
}
?>
控制器::
$data['get_all_content'] = $this->admin_user->list_rows();
的print_r ::
Array
(
[0] => Array
(
[id] => 1
[menu_id] => 12
[title] => Register Domain name for free
[sub_title] => This is the sub_title
[content] => this is the content description
[description] =>
[section] =>
)
)
你'的print_r($數據[ 'get_all_content'];'?你在哪裏得到你的'print_r()'? – aldrin27
是的,它返回,我在視圖Array([0] =>陣列([id] => 1 [menu_id] => 12 [title] =>免費註冊域名[sub_title] =>這是sub_title [內容] =>這是內容描述[description] => [section] =>)) – wicky
但是,當你這樣做'$ title = $ values ['title'];'你會得到標題? – aldrin27