I wish to replace all links during my primary menu with http every time they are https

I've attempted the function below however it doesn't have effect

function wp_list_pages_custom() {

$array = array();

$pages = wp_nav_menu( array( 
  'menu'            => 'Main Menu', 
  'menu_id'         => 'menu',  
  'echo'            => true,
  'fallback_cb'     => 'wp_page_menu',
  'before'          => '',
  'after'           => '',
  'depth'           => 0
));

$pages = str_replace('https', 'http', $pages);

echo $pages;

}

Based on the documentation of wp_nav_menu, the echo parameter must be false to be able to obtain the menu just came back rather than printed. So presently you most likely possess the menu printed two times. It's also wise to check if the method returns absolute Web addresses or relative Web addresses.

function wp_list_pages_custom() {

$array = array();

$pages = wp_nav_menu( array( 
  'menu'            => 'Main Menu', 
  'menu_id'         => 'menu',  
  'echo'            => false,
  'fallback_cb'     => 'wp_page_menu',
  'before'          => '',
  'after'           => '',
  'depth'           => 0
));

$pages = str_replace('https', 'http', $pages);

echo $pages;

}

you'd echo true, therefore the function handles the output