Codeigniter: Severity notice Message Array to String conversion
<p>I am new to this and failed to understand why this is happening. I am getting result from database they are:</p>

<pre><code>ArrayArray ( [0] =&gt; stdClass Object ( [id] =&gt; 1 [box] =&gt; draggable1 [xorder] =&gt; 1 [descp] =&gt; Y ) [1] =&gt; stdClass Object ( [id] =&gt; 2 [box] =&gt; draggable2 [xorder] =&gt; 2 [descp] =&gt; Z ) [2] =&gt; stdClass Object ( [id] =&gt; 3 [box] =&gt; draggable3 [xorder] =&gt; 3 [descp] =&gt; X ) ) 
</code></pre>

<p>I am  trying to print single value such as printing only <code>id value 1</code> or <code>box value draggable1</code> from list of array. But problem is when i apply</p>

<pre><code>echo $result1['data'];
</code></pre>

<p><strong>gives error:</strong></p>

<pre><code>Severity: Notice
Message Array to String conversion 
</code></pre>

<p>similarly while further trying by doing:</p>

<pre><code>echo $result1['data']['id']; //id is field name
</code></pre>

<p><strong>gives me error:</strong></p>

<pre><code>undefined index : id
</code></pre>

<p>and lastly when i got tired did this:</p>

<pre><code>print_r($result1['data'][0]);
</code></pre>

<p>and <strong>printed the result</strong></p>

<pre><code>stdClass Object ( [id] =&gt; 1 [box] =&gt; draggable1 [xorder] =&gt; 1 [descp] =&gt; Y ) 
</code></pre>

<p>but when i do so:</p>

<pre><code>print_r($result1['data'][0]['id']);
</code></pre>

<p><strong>gives error:</strong></p>

<pre><code>Fatal error: Cannot use object of type stdClass as array
</code></pre>

<p>i follow this post which is related to me but i dont know why i am unable to do so <a href="https://stackoverflow.com/questions/10684329/codeigniter-displaying-query-result-in-controller">Codeigniter : displaying query result in controller</a></p>

<p>Here is my function:</p>

<pre><code>public function index()
    {
        $id=$this-&gt;input-&gt;post('name');
        $result1['data']=$this-&gt;drag_model-&gt;getcoordinates();
        $result2['data']=$this-&gt;drag_model-&gt;getva($id);

        echo $result1['data']['id'];
        print_r($result1['data'][0]['id']);
    //  array('id'=&gt;);
        //  $this-&gt;load-&gt;view('drag/drag_view');
        $this-&gt;load-&gt;view('drag/dragswap',$result1);

    //  $this-&gt;load-&gt;view('LoginN/login_view');

    }
</code></pre>