Welcome Guest, Not a member yet? Register   Sign In
How to echo this array?
#2

Well your question is a bit unclear. $data['content'] is the array $data with an element 'content'. Is the array you have shown the element 'content' or the array $data itself?

In your controller something like:
PHP Code:
public function index()
{
 
   $data = array();

 
   $content = array(
 
       array(
 
           'subject_name' => 'Maths',
 
           'subject_author' => 'Peter',
 
       ),
 
       array(
 
           'subject_name' => 'English',
 
           'subject_author' => 'John',
 
       ),
 
   );
 
   $data['content'] = $content;

 
   $this->load->view('homepage'$data);


In your 'homepage.php' view file something like:
PHP Code:
<?php if ( ! empty($content)) { ?>

     <?php foreach ($content as $item) { ?>

          <?php echo $item['subject_name']; ?>
          <?php echo $item['subject_author']; ?>

     <?php ?>

<?php ?>

I hope that helps but perhaps you were asking something more complicated that I have missed.

Best wishes

Paul.
Reply


Messages In This Thread
How to echo this array? - by iridion2015 - 10-10-2017, 05:13 AM
RE: How to echo this array? - by PaulD - 10-10-2017, 06:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB