Use array_slice correctly.

From #6499.