This should be:

    if (!isset($index['key']) || count($index['key']) < $numFields) {