You'd better do reset($name) instead of $name[0]. This way it will work even if the key is not an integer.