You can use sscanf
:
Example:
print_r( sscanf("+123-1234-1234", "+%3d-%4d-%4d") );
will output:
Array ( [0] => 123 [1] => 1234 [2] => 1234 )
This will not guarantee the validity of the input string though. A string like +1-1-1 would result in array having all three values with 1. So you still have to validate the three array values separately.
See the list of supported formats (not sure PHP supports all of these though).
But seriously, ^\+\d{3}-\d{4}-\d{4}$
is not something to be scared of. It’s reasonably simple. There is much worse in Regex Land.
3
solved How do I check string in this format: +xxx-yyyy-zzzz? [closed]