Guest User

Untitled

a guest
Jul 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. $mobile_array = explode(",",$mobile_list); // turn into an array
  2. $landlines = array_count_values($mobile_array); // create count variable
  3. echo $landlines["020..."]; // print the number of numbers
  4.  
  5. $mobile_list = '02000, 02032435, 039002300, 00305600';
  6. $mobile_array = explode(",",$mobile_list); // turn into an array
  7. $landlines = array_count_values($mobile_array); // create count variable
  8. $sequence = '020'; // print the number of numbers
  9.  
  10.  
  11.  
  12. function filter_phone_numbers($mobile_array, $sequence){
  13. return array_filter($mobile_array, function ($item) use ($sequence) {
  14. if (stripos($item, $sequence)) {
  15. return true;
  16. }
  17. return false;
  18. });
  19. }
  20.  
  21. $filtered_items = filter_phone_numbers($mobile_array, $sequence);
  22.  
  23. echo count($filtered_items);
  24.  
  25. $mobile_list = '02000, 02032435, 039002300, 00305600';
  26. $mobile_array = explode(",",$mobile_list); // turn into an array
  27. $landlines = array_count_values($mobile_array); // create count variable
  28. $sequence = preg_quote('020', '~'); ; // print the number of numbers
  29.  
  30.  
  31.  
  32. function grep_phone_numbers($mobile_array, $sequence){
  33.  
  34. return preg_grep('~' . $sequence . '~', $mobile_array);
  35.  
  36. }
  37.  
  38. $filtered_items = grep_phone_numbers($mobile_array, $sequence);
  39.  
  40. echo count($filtered_items);
  41.  
  42. $numbers = [
  43. '07000000000',
  44. '02000000000',
  45. '07000000000',
  46. '07000000000',
  47. '02000000000',
  48. ];
  49. function landlineCount($carry, $item)
  50. {
  51. if (substr($item, 0, 3) === '020') {
  52. return $carry += 1;
  53. }
  54.  
  55. return $carry;
  56. }
  57.  
  58.  
  59. $count = array_reduce($numbers, 'landlineCount');
  60.  
  61. echo $count;
  62.  
  63. SELECT * FROM phone_numbers WHERE number LIKE '020%'
  64.  
  65. $mobile_list = "071234567890,02039989435,0781,020122,123020";
  66.  
  67. preg_match_all("/b020d+b/", $mobile_list, $m);
  68. var_dump($m);
  69. echo count($m[0]); // 2
  70.  
  71. $no = "020XXXXXXX";
  72.  
  73. if (strpos($no, '020') !== false) {
  74. echo 'its a landline number';
  75. }
Add Comment
Please, Sign In to add comment