数组无法在CI中显示

时间:2014-09-19 04:14:42

标签: php arrays codeigniter foreach

这是我的PHP代码: -

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

我无法在视图中显示他们的数据....

1 个答案:

答案 0 :(得分:0)

$data['myarray']=Array
(
[cus] => Anand Roy
[depart] => science
[add1] => sdfrfrferwfrfrfeferv
[add2] => veververv eververv
[cty] => Jalpaiguri
[pin] => 735101
[st] => West Bengal
[em] => cosmilisation@gmail.com
[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
}