我有以下数组响应:
[0] => Array ([taxname] => Service tax @ 14% [taxamount] => 140000)
[1] => Array ([taxname] => swachh bharat cess @ 0.5% [taxamount] => 5000) [rowcount] => 2)
我使用以下代码在视图中显示结果:
<?php
for($i=0;$i<$rowcount;$i++)
{
echo $i['taxName'];
}
?>
但没有显示任何内容。
答案 0 :(得分:1)
[0] => Array ( [taxname] => Service tax @ 14% [taxamount] => 140000 ) [1] => Array ( [taxname] => swachh bharat cess @ 0.5% [taxamount] => 5000 ) [rowcount] => 2 )
consider an $array = array('taxname'=>'Service tax @ 14% ');
//if you are sending from the controller:
$data['myarray'] = $array;
$this->load->view('viewfile',$data);
In the View:
foreach($myarray as $key=>$value){
echo $value;
}
echo $myarray['taxname'];