_only 发表于 2023-1-7 12:44:12

使用preg_grep()函数

使用preg_grep()函数

<style type = "text/css">
<!--
body,td,th{
    font-size:12px;
}
body {
      margin-left:10px;
      margin-top:10px;
      margin-right:10px;
      margin-bottom:10px;
}
-->
</style></head>
<body>
<?php
      $preg = '/\d{3,4}-?\d{7,8}/';
      $arr = array('043212345678','0431-7654321','12345678');
      $preg_arr = preg_grep($preg,$arr);
      var_dump($preg_arr);
?>


执行结果:
array(2) {=>string(12) "043212345678"=>string(12) "0431-7654321" }

nihaolai 发表于 2023-2-17 21:19:45

好好好好好好好好好好好好好好好好好顶
页: [1]
查看完整版本: 使用preg_grep()函数