Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter - Accessing multi-dimentional array
    primarykey
    data
    text
    <p>So I have problem in accessing value in multidimentional array. Here's print_r result/array structure of my $klasemen->data:</p> <blockquote> <pre><code>Array ( [0] =&gt; stdClass Object ( [team] =&gt; stdClass Object ( [id] =&gt; 5055 [name] =&gt; Manchester United ) [breadcrumb] =&gt; Array ( [0] =&gt; stdClass Object ( [id] =&gt; 1 [name] =&gt; Bola ) [1] =&gt; stdClass Object ( [id] =&gt; 2 [name] =&gt; Internasional ) [2] =&gt; stdClass Object ( [id] =&gt; 23 [name] =&gt; Liga Premiere ) ) [games_played] =&gt; 23 [wins] =&gt; 18 [draws] =&gt; 2 [losses] =&gt; 3 [goals_scored] =&gt; 57 [goals_against] =&gt; 30 [goals_difference] =&gt; 27 [points] =&gt; 56 ) [1] =&gt; stdClass Object ( [team] =&gt; stdClass Object ( [id] =&gt; 5057 [name] =&gt; Manchester City ) [breadcrumb] =&gt; Array ( [0] =&gt; stdClass Object ( [id] =&gt; 1 [name] =&gt; Bola ) [1] =&gt; stdClass Object ( [id] =&gt; 2 [name] =&gt; Internasional ) [2] =&gt; stdClass Object ( [id] =&gt; 23 [name] =&gt; Liga Premiere ) ) [games_played] =&gt; 23 [wins] =&gt; 15 [draws] =&gt; 6 [losses] =&gt; 2 [goals_scored] =&gt; 45 [goals_against] =&gt; 19 [goals_difference] =&gt; 26 [points] =&gt; 51 ) </code></pre> </blockquote> <p>I want to access the name of competition (eg. Liga Premiere) and print it on my view but I keep getting <strong>"Message: Trying to get property of non-object"</strong>. I believe something's wrong with the syntax or my way accessing array in Breadcrumb array. I'm new and I get confused with this multidimentional array thing T_T</p> <p>Here's the line code on my view when I want to print the value (I'm pretty sure something's wrong with it).</p> <blockquote> <p>echo $klasemen->data->breadcrumb[2]->name</p> </blockquote> <p>Anyway $klasemen is variable that contains all data. Anyone can help me with this? Thank you! :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload