未定义的偏移量和尝试获取非对象的属性

I learned php in 2003 and have not really kept up with changes. I had the following function built for me in 2014. I just updated to php 7.3 and am getting these notices (although everything works fine). Please help me with what needs to change ion order to comply with 7.3 and not have these notices.

Here is the function:

add_filter( 'wp_nav_menu_objects', 'church_nav_menu_objects_filter',10,2);
function church_nav_menu_objects_filter( $items, $args ) {
    if (( isset($_SESSION["church"])) && (!empty($_SESSION['church']))) {
    //print "<pre>items:<br>
";
    //var_dump( $items );
    //print "</pre><br>
";
        if ( is_array( $items ) ) {
            for( $i=0 ; $i < count($items) ; $i++ ) {
                if (( strpos($items[$i]->url,"thetrinitymission.org" )) && ( ! strpos($items[$i]->url,$_SESSION["church"]) ) ) $items[$i]->url=str_replace("thetrinitymission.org",$_SESSION["church"].".thetrinitymission.org",$items[$i]->url);
        }
    }
  }

return( $items );
}

I get the following errors: Notice: Undefined offset: 0 in /thetrinitymission.org/wp-content/themes/twentynineteenkid/functions.php on line 360

Notice: Trying to get property 'url' of non-object in /thetrinitymission.org/wp-content/themes/twentynineteenkid/functions.php on line 360

Line 360 is the one that starts: if (( strpos($items[$i]->url,

$items is apparently an associative array with string indexes, it's not indexed numerically. Change the loop to use foreach instead of for.

foreach ($items as $item) {
    if (( strpos($item->url,"thetrinitymission.org" )) && ( ! strpos($item->url,$_SESSION["church"]) ) ) {
        $item->url=str_replace("thetrinitymission.org",$_SESSION["church"].".thetrinitymission.org",$item->url);
    }
}