0

I have the following array response:

[0] => Array ([taxname] => Service tax @ 14% [taxamount] => 140000) 
[1] => Array ([taxname] => swachh bharat cess @ 0.5% [taxamount] => 5000) [rowcount] => 2)

I am using the following code for display the result in view:

<?php   

    for($i=0;$i<$rowcount;$i++)
    {
        echo $i['taxName'];
    }

?>

But nothing is displayed.

2
  • 2
    add your complete code. Model controller and view Commented Aug 25, 2016 at 11:05
  • 1
    Think about what exactly the value $i is in each iteration. Otherwise place print_r($i); inside the loop Commented Aug 25, 2016 at 11:06

1 Answer 1

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'];
Sign up to request clarification or add additional context in comments.

1 Comment

@user3833740 if this answer works you should accept the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.