I want remove http:// and https:// form all of url in my form submit. So I used below code to remove http:// and make next process. If I used something with http:// in input its not work and go to my error page.
Now I want to direct remove http:// or https:// form all of submit url. 
I also read here about str_replace and preg_replace but cannot understand how to apply this here.
$web = mysqli_real_escape_string($dbh, $_POST['web']);
$fb = mysqli_real_escape_string($dbh, $_POST['fb']);
$tw = mysqli_real_escape_string($dbh, $_POST['tw']);
$gg = mysqli_real_escape_string($dbh, $_POST['gg']);
$keys = array('web','fb','tw','gg');
$invalid_strings = array("http://","https://");
   foreach($keys as $key) {    # iterate through each key to check
      foreach($invalid_strings as $invalid) {   # iterate through each invalid string
         if(strpos($_POST[$key], $invalid) === 0) {
     return str_replace($invalid, '', $_POST[$key]);
         }
      }
   }
   // Update process query
 
     
     
     
    