0

I have string whom fetch from database but all having different format so how can i fetch phone numbers from that strings

String Examples

user name;foo@foo.com;0373XXXXXX;fooo;ccc    
user name;foo@foo.com;fooo;0373XXXXXX;ccc    
user name;0373XXXXXX;foo@foo.com;fooo;ccc 

and here 0373XXXXXX is 10 digit phone number of user

sagar patel
  • 591
  • 5
  • 18

1 Answers1

2

Use below code :

<?php

$string = "user name;foo@foo.com;0373123456;fooo;ccc";

preg_match_all('!\d+!', $string, $matches);
print_r($matches);

?>

Hope it will help you :)

Milan
  • 631
  • 1
  • 5
  • 21