Question: what is undefined offset 0?
Answer: You are asking for the value at key 0 of $votes . It is an array that does not contain that key. The array $votes is not set, so when PHP is trying to access the key 0 of the array, it encounters an undefined offset for [0] and [1] and throws the error.