fix php warnings when empty var is given to foreach