2
array(2) {
  [0]=>
  object(stdClass)#21 (7) {
    ["id"]=>
    string(1) "1"
    ["title"]=>
    string(7) "cvxzcvd"
    ["con"]=>
    string(10) "gvsdvgsdfg"
    ["is_important"]=>
    string(1) "1"
    ["date"]=>
    string(3) "123"
    ["image"]=>
    string(2) "55"
    ["cat_id"]=>
    string(1) "1"
  }
  [1]=>
  object(stdClass)#22 (7) {
    ["id"]=>
    string(1) "2"
    ["title"]=>
    string(4) "fsdf"
    ["con"]=>
    string(9) "dfdsfvfds"
    ["is_important"]=>
    string(1) "1"
    ["date"]=>
    string(4) "5145"
    ["image"]=>
    string(7) "5454124"
    ["cat_id"]=>
    string(1) "2"
  }
}

I passed this array into a view

$this->load->view('home/index',$news_data);

but I wanna use the data separately. I mean if I wanna use the second title or the second data. how can I express that in the view

thanks

2
  • $news_data[1] Commented Sep 8, 2017 at 1:50
  • How are you getting the array via database model function? Commented Sep 8, 2017 at 4:24

2 Answers 2

1

You can go like this:-

$news_data[1]->title;
$news_data[1]->data;
Sign up to request clarification or add additional context in comments.

Comments

1

Store the array into variable like

$news_data['arr'] = { } ;

,and in view file access it by $arr;

print_r($arr);

Comments

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.