|
使用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) { [0]=> string(12) "043212345678" [1]=> string(12) "0431-7654321" }
|
|