You want to use preg_match_all , not preg_match
preg_match_all('/[(]*\d{3}[)]*\s*[.\- ]*\d{3}[.\- ]*\d{4}/', $check, $phone_matches); print_r($phone_matches);
But note that sizeof($phone_matches) will still be 1, since the array of matches is actually $phone_matches[0] .
To repeat all the matches you make:
foreach ($phone_matches[0] as $match) {
But for what you are actually trying to execute, there is no need for preg_match_all at all. A simple single line preg_replace will do the trick:
$check = preg_replace('/[(]*\d{3}[)]*\s*[.\- ]*\d{3}[.\- ]*\d{4}/', '<span class="hide">$0</span><span class="show">show phone</span>', $check);
source share