- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$value = '123456-1234567890';
if (! preg_match('/((\d{0,6})-)?(\d{1,10})/', $value, $matches)) {
echo 'nope';
}
print_r($matches);
if (!$matches[1]) {
echo 'test';
}