You can just move this `foreach` out of the `if-else` block. `$rule['action']` is always an array.