The following code works well in PHP but in PHP 7 it gives an error:
Can not use string offset as an array
How can I solve the line with error in the following code?
if (empty($node['courses'])) {
return '';
}
$result = '<ul>';
$coursecount = 0;
foreach ($node['courses'] as $course) {
if (empty($course['certs'])) {
continue;
if (!isset($result['courses'][$coursename])) {
$result['courses'][$coursename] = array('name' => $coursename, 'certs' => array());
}
if (!isset($result['course'][$coursename]['certs'][$issuecert->code])) {
$result['courses'][$coursename]['certs'][$issuecert->code] = $issuecert;
}
}
}