- preg_match: documentation ( source)
<?php
$phone_number = '+380936109511';
$phone_number = '093610911';
//$phone_number = 'wtf';
if ( ! preg_match('/\d{12}/', $phone_number) && ! preg_match('/\d{10}/', $phone_number))
{
throw new Exception('Not valid phone number format');
}