<?php
$tests = [
'+2347036756899',
'+234-7036-756899',
'+2347036-756899',
'+234-7036756899',
'07036756899',
'0-7036756899',
'07036-756899',
'08036756899',
];
foreach ($tests as $test) {
printf(
"%20s : %s\n",
$test,
preg_match('/^(?:\+234(-)?|0)(?:[78]0|81)\d{2}(?(1)-|)\d{6}$/', $test) ? '✅' : '❌'
);
}
- Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- +2347036756899 : ✅
+234-7036-756899 : ✅
+2347036-756899 : ❌
+234-7036756899 : ❌
07036756899 : ✅
0-7036756899 : ❌
07036-756899 : ❌
08036756899 : ✅
preferences:
78.81 ms | 402 KiB | 61 Q