Replace all `foreach` occurences

As 0.9.12 depreciates these functions