jcadima
5/27/2015 - 9:09 PM

Remove unwanted characters from POST submit values

Remove unwanted characters from POST submit values

<?php 

// Remove  formatting MobilePhone
function getMobile() {
  $remove_chars = array("(", ")" , "-") ; // unwanted chars array
  $formatted_phone = filter_input(INPUT_POST, "MobilePhone") ;
  $mobile_number = str_replace($remove_chars, "", $formatted_phone); // remove dashes, replace with empty string
  return $mobile_number  ;
}