Why my array empty

Why my array empty

by MOHAMAD AMAR IZATY AHMAD RAZUAN -
Number of replies: 0

$cms = array();
$modinfo = get_courses();
foreach ($modinfo->cms as $id => $othercm) {
$cms[] = (object)array('id' => $id,
'name' => format_string($othercm->fullname, true, array('context' => $context)),
'completiongradeitemnumber' => $othercm->shortname);
}
var_dump($cms);die();

any error?

Average of ratings: -