<?php $pattern = "/[0-9]{3}-[0-9]{4}/"; $test = "111-2222"; $cnt = preg_match($pattern, $test, $matches); var_dump($cnt); echo "<br />"; var_dump($matches); ?>