I would like to allow numbers and the following characters: -
, +
, (
, )
$phone = '1(54)+45-21';
var_dump(preg_match('/^[\(\)0-9+-]+$/', $phone));
Well, that works great. But I would also like to allow spaces between each character. So the value of $phone
could be like +45 (548) - 541 55 11
but it would also be valid without any spaces.
How can I allow optional spaces?