遍历三个不同的数组

时间:2019-05-07 00:07:47

标签: php foreach

我试图遍历存储在allPhones数组[]中的三个数组(phoneHome [],phoneMobile [],phoneWork [])。 另外,使用preg_match_all查看获得一个正确的电话号码,但不会循环。

$phoneHome[] = str_replace('-','',$row['Phonehome']);
$phoneMobile[]= str_replace('-','',$row['Phonemobile']);
$phoneWork[] = str_replace('-','',$row['Phonework']);
$time[] = ($row['apptTime']);


$allPhones =array($phoneHome,$phoneMobile,$phoneWork);
$allrecord = [$allPhones,$address,$time];


foreach (($allPhones as $str ){
    $phoneNumberValidate = "/^(?:\+?61|0)4 ?(?:(?:[01] ?[0-9]|2 ?[0-57-9]|3 ?[1-9]|4 ?[7-9]|5 ?[018]) ?[0-9]|3 ?0 ?[0-5])(?: ?[0-9]){5}/";

    if (preg_match_all ($phoneNumberValidate,$str, $m)){
    }

    elseif(preg_match_all($phoneNumberValidate,$str[1], $m)) {
    }

    elseif(preg_match_all($phoneNumberValidate,$str[2], $m)) {
    }

    //var_dump($matches);
}

$matches = $m[];

预期结果应为三个数组中的10条记录给出10个匹配的数字。

0 个答案:

没有答案