Weird PHP bug with returning first element from array