function number_only($val){
  $repNumber = str_split("!@#$%^&*()_-=+|\][[`~'\";:/?.>,<{}qwertyuioplkjhgfdsazxcvbnm");
  return intval(str_replace($repNumber, '', $val));
}
echo number_only("abcd12345!@#$%"); //output 12345

Comment