2014-09-19 56 views
0

,顯示這裏是我的PHP代碼: -陣列是不是能夠在CI

Array 
(
    [cus] => Anand Roy 
    [depart] => science> 
    [add1] => sdfrfrferwfrfrfeferv 
    [add2] => veververv eververv 
    [cty] => Jalpaiguri 
    [pin] => 735101 
    [st] => West Bengal 
    [em] => [email protected] 
    [tele] => 919641758183 
    [fax] => 
    [admin] => uh 
    [aphn] => 919641758183 
    [bill] => khkj 
    [bphn] => 919641758183 
    [key] => khkj 
    [kphn] => 919641758183 
    [am] => 1 am 
    [pm] => 1 pm 
    [week] => 
) 

餘米無法在視圖中顯示其數據....

回答

0
$data['myarray']=Array 
(
[cus] => Anand Roy 
[depart] => science 
[add1] => sdfrfrferwfrfrfeferv 
[add2] => veververv eververv 
[cty] => Jalpaiguri 
[pin] => 735101 
[st] => West Bengal 
[em] => [email protected] 
[tele] => 919641758183 
[fax] => 
[admin] => uh 
[aphn] => 919641758183 
[bill] => khkj 
[bphn] => 919641758183 
[key] => khkj 
[kphn] => 919641758183 
[am] => 1 am 
[pm] => 1 pm 
[week] => 
); // initialize your array 
$this->load->view("viewfile",$data); // pass the array to your view page 

而在你viewfile,訪問它像:

foreach($myarray as $array) // foreach array elements 
{ 
    echo $array['cus'];   // echo it based on array index 
} 
+0

$ this-> load-> view(「viewfile」,$ data); ? – 2014-09-19 04:23:50

+0

嘗試https://ellislab.com/codeigniter/user-guide/general/views.html – 2014-09-19 04:25:12

+0

@ RakeshSharma ..如果我們需要傳遞給另一個控制器的視圖文件,那麼我們必須指定控制器/視圖文件夾名稱。 – Jenz 2014-09-19 04:26:18