diff --git a/app/controllers/my_courses.php b/app/controllers/my_courses.php
index 21cde0e1fdb9cc69e6b69aa9ff033a7d6c4c61cf..395bef9b02a873ba809cfc4100838769354dd315 100644
--- a/app/controllers/my_courses.php
+++ b/app/controllers/my_courses.php
@@ -194,7 +194,6 @@ class MyCoursesController extends AuthenticatedController
                 'responsive_type'          => Config::get()->MY_COURSES_ALLOW_TILED_DISPLAY && $GLOBALS['user']->cfg->MY_COURSES_TILED_DISPLAY_RESPONSIVE ? 'tiles' : 'tables',
                 'navigation_show_only_new' => $GLOBALS['user']->cfg->MY_COURSES_SHOW_NEW_ICONS_ONLY,
                 'group_by'                 => $this->getGroupField(),
-
             ],
         ];
 
@@ -1055,6 +1054,7 @@ class MyCoursesController extends AuthenticatedController
                 uksort($course['navigation'], function ($a, $b) use ($positions) {
                     return array_search($a, $positions) - array_search($b, $positions);
                 });
+                $course['navigation'] = array_values($course['navigation']);
                 return $course;
             },
             $courses
diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php
index 522dc8b766c040500bb90f4714dd978f9cdf5086..7421058bfdd01491c647fb691f378d3e05234a85 100644
--- a/lib/classes/MyRealmModel.php
+++ b/lib/classes/MyRealmModel.php
@@ -880,16 +880,16 @@ class MyRealmModel
      */
     public static function array_rtrim($array)
     {
-        $temp  = array_reverse($array);
+        $temp  = array_reverse($array, true);
         $empty = true;
 
         while ($empty && !empty($temp)) {
             $item = reset($temp);
             if ($empty = ($item === null)) {
-                $temp = array_slice($temp, 1);
+                $temp = array_slice($temp, 1, null, true);
             }
         }
-        return array_reverse($temp);
+        return array_reverse($temp, true);
     }
 
     /**