<?php
$areaCodes = array();
$threeDigits = array();
$fourDigits = array();
preg_match_all('/(\d{3})-(\d{3})-(\d{4})/',$content,$matches);
if(count($matches[1])>0)
{
for($i=0; $i<count($matches[1]); $i++)
{
array_push($areaCodes,$matches[1][$i]);
array_push($threeDigits,$matches[2][$i]);
array_push($fourDigits,$matches[3][$i]);
}
}
preg_match_all('/\((\d{3})\)-(\d{3})-(\d{4})/',$content,$matches);
if(count($matches[1])>0)
{
for($i=0; $i<count($matches[1]); $i++)
{
array_push($areaCodes,$matches[1][$i]);
array_push($threeDigits,$matches[2][$i]);
array_push($fourDigits,$matches[3][$i]);
}
}
preg_match_all('/(\d{3}).(\d{3}).(\d{4})/',$content,$matches);
if(count($matches[1])>0)
{
for($i=0; $i<count($matches[1]); $i++)
{
array_push($areaCodes,$matches[1][$i]);
array_push($threeDigits,$matches[2][$i]);
array_push($fourDigits,$matches[3][$i]);
}
}
preg_match_all('\((\d{3})\).(\d{3}).(\d{4})/',$content,$matches);
if(count($matches[1])>0)
{
for($i=0; $i<count($matches[1]); $i++)
{
array_push($areaCodes,$matches[1][$i]);
array_push($threeDigits,$matches[2][$i]);
array_push($fourDigits,$matches[3][$i]);
}
}
print_r($areaCodes);
print_r($threeDigits);
print_r($fourDigits);
而且?你想我們爲你寫嗎? – xbonez
這不是phpfreaks(其中您將有更好的機會編寫代碼)。至少先嚐試一下。 –
我有這個到目前爲止,但它不工作時,在同一行上有其他數字,如街道地址數字: – califmerchant