How can I fix: “Notice: Undefined offset: 0”?

You’re looking in WordPress core files for the cause of the PHP notice, which is a waste of time, as 1) I doubt you’ve found a new bug in WordPress, and 2) you don’t want to modify WordPress core files to fix a theme or plugin issue, and 3) the error is caused by a theme or plugin and not WordPress core, but shows up in the PHP notice as pointing to core files.

And besides all that, it’s a PHP notice. Not an error, not a fatal error, but a notice. All that means is “hey, look at me, you might want to fix me at some point, but I’m not an error.” Read https://stackoverflow.com/questions/4624474/php-difference-between-notice-and-warning

NOTICE: It is a message for saying what you should do and what you
should not do.

WARNING: It occurs at run time.But it do not interrupt Code execution.

ERROR: It also occurs at run time, but program execution is not
continued it terminates.

So check in wp-config.php and turn off debug so you don’t see the notices https://codex.wordpress.org/Debugging_in_WordPress Or check in php.ini of your hosting account; see https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display

To more effectively find the cause of an PHP error or notice, use Debug as linked above. But the simplest thing to do is deactivate all plugins and reactivate until you find the one that throws the notice. Then ask the plugin for help or look in their forums. Or, if a plugin is not the cause, switch to the default WordPress theme and see if the notice is in the error logs recorded by wp_debug.