I am trying to retrieve a value from an Array. Here is the code:
$opt=get_records_sql($sql1);
print_object($opt);
$n = count($opt);
if (empty($opt)){
echo 'No options selected';
}
else{
$optno = $opt["subjectid"];
echo '<br>$optno = '.$optno;
}
I tried to use: $opt["subjectid"] but I get the following error:
Notice: Undefined index: subjectid
Contents of array:
Array
(
[1] => stdClass Object
(
[uname] => JHollands06
[tutor] => M LSt
[subjectid] => 1
[year] => 2010
[optid] => 1
)
)
How to I fetch the data subjectid which has value 1?