php提取字符串中的数字

    function findNum($str=''){

      $str=trim($str);
        if(empty($str)){
          return '';
        }
      $temp=array('1','2','3','4','5','6','7','8','9','0');
      $result='';
      for($i=0;$i<strlen($str);$i++){
        if(in_array($str[$i],$temp)){
          $result.=$str[$i];
        }
      }
      return $result;
    }

  

猜你喜欢

转载自www.cnblogs.com/dalaowang/p/10735046.html