Simply because this code is based on the previous code. :)

But in any case, the foreach loop is better here, as we don't create a copy of the whole table to add the new values in the array. Which is much more efficient, memory-wise. Also, it's not like adding two more lines make the code any less readable here.