diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index eb3baa0d8f12..baf498f0e47d 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -831,11 +831,11 @@ public function resource(string $name, array $options = null): RouteCollectionIn if (isset($options['except'])) { $options['except'] = is_array($options['except']) ? $options['except'] : explode(',', $options['except']); - foreach ($methods as &$method) + foreach ($methods as $i => $method) { if (in_array($method, $options['except'])) { - unset($method); + unset($methods[$i]); } } } @@ -945,11 +945,11 @@ public function presenter(string $name, array $options = null): RouteCollectionI if (isset($options['except'])) { $options['except'] = is_array($options['except']) ? $options['except'] : explode(',', $options['except']); - foreach ($methods as &$method) + foreach ($methods as $i => $method) { if (in_array($method, $options['except'])) { - unset($method); + unset($methods[$i]); } } }