PHP - Get values from Array
<p>I am trying to get a record from a database using an sql lookup (sql1). This then returns as an array which is fine, but I need to use part of the array for my next stage.</p>

<p>$opt=get_records_sql($sql1);</p>

<pre><code>    //Diags for SQL content
        print_object($opt);

    $n = count($opt);
    if (empty($opt))
        {
        echo 'No options selected';
        }
    else
        {

        $optno = $opt["subjectid"];

        // Diags of $optno
            echo '&lt;br&gt;$optno = '.$optno;
</code></pre>

<p>As you can see, I tried to use this: $opt["subjectid"] as subjectid is the fieldname that I am trying to access and I was under the impression that this was correct for accessing an array, but I get the following error:</p>

<pre><code>Notice: Undefined index: subjectid
</code></pre>

<p>Array contents:</p>

<pre><code>Array
(
    [1] =&gt; stdClass Object
        (
            [uname] =&gt; JHollands06
            [tutor] =&gt; M LSt
            [subjectid] =&gt; 1
            [year] =&gt; 2010
            [optid] =&gt; 1
        )

)
</code></pre>
