Wednesday, 25 July 2018

PHP - get total number of array items with a specific number sequence in value

So, basically I'm trying to count the number of landline phone numbers in a list of both landlines and mobile phone numbers $mobile_list (071234567890,02039989435,0781...)

$mobile_array = explode(",",$mobile_list);        // turn into an array
$landlines = array_count_values($mobile_array);  // create count variable
echo $landlines["020..."];                      // print the number of numbers

So, I get the basic count specific elements function, but I don't see where I can specify if an element 'starts with' or 'contains' a sequence. With the above you can only specify an exact phone number (obviously not useful).

Any help would be great!



from PHP - get total number of array items with a specific number sequence in value

No comments:

Post a Comment