I'm trying to validate phone numbers posted on a contact form
I don't want to be too strict and perhaps block any users from submitting the form with a perfectly OK phone number
Instead, the phone no. should just contain at least (let's say) 6 number digits in total
The string can be anything in any order.. "(44) 123hello88you987howareyou565"
Right now I have this
if (!preg_match('/(\d{6,})/', $phone)) { // throw error }
But it only considers joined numbers
Allow other characters in between the digits:
!preg_match('/(?:\D*\d){6,}/', $phone)