I have an array like below :
Array ( [3] =>
stdClass Object (
[Course_ID] => php01
[Course_Type] => E
[Course_Name] => PHP
[Service] => 3L
[Valid_Start_Date] => 2015-11-05
[Valid_End_Date] => 2016-01-31
[Duration] => 3
[Re_cert_Years] => 0
[LMS_Course_ID] => 123
[id] => 3
)
[21] =>
stdClass Object (
[Course_ID] => php01
[Course_Type] => E
[Course_Name] => PHP
[Service] => 3L
[Valid_Start_Date] => 2015-11-05
[Valid_End_Date] => 2016-01-31
[Duration] => 3
[Re_cert_Years] => 0
[LMS_Course_ID] => 123
[id] => 21
)
)
i want to get the value of Course_ID.
How to get the value from this array ?
For accessing Object key in PHP use ->
operator Have you tried like following:
foreach($ret as $index=>$obj){
echo $obj->Course_ID;
}
It will print 2 courseID because your array of object contains 2 object. if you want to print any particular index then use this:
echo $ret[3]->Course_ID;
echo $ret[21]->Course_ID; //where 3 or 21 is index of array