Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. define("REGEXP_MULTIPLE_NAMES", "/^[a-zA-Zs-]+$/i");
  2.  
  3. //Expression to check Dutch phone numbers. Number must start with zero and number of digits should be 10. Different area and country codes are allowed.
  4. define("REGEXP_PHONE_NL", "/(^+[0-9]{2}|^+[0-9]{2}(0)|^(+[0-9]{2})(0)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9-s]{10}$)/");
  5.  
  6. $data = array(
  7. 'city' => 'The hague',
  8. 'telephonenr' => '0701234567'
  9. );
  10. $args = array(
  11. 'city' => array(
  12. 'filter' => FILTER_VALIDATE_REGEXP,
  13. array(
  14. "options" => array(
  15. "regexp" => REGEXP_MULTIPLE_NAMES
  16. )
  17. )
  18. ),
  19. 'telephonenr' => array(
  20. 'filter' => FILTER_VALIDATE_REGEXP,
  21. array(
  22. 'options' => array(
  23. "regexp" => REGEXP_PHONE_NL
  24. )
  25. )
  26. )
  27. );
  28.  
  29. $myinputs = filter_var_array($data, $args);
  30. print_r($myinputs);
  31.  
  32. $args = array(
  33. 'city' => array(
  34. 'filter' => FILTER_VALIDATE_REGEXP,
  35. 'options' => array(
  36. "regexp" => REGEXP_MULTIPLE_NAMES
  37. )
  38. ),
  39. 'telephonenr' => array(
  40. 'filter' => FILTER_VALIDATE_REGEXP,
  41. 'options' => array(
  42. "regexp" => REGEXP_PHONE_NL
  43. )
  44. )
  45. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement