Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get list of phone numbers
function getContacts($data)
{
$contacts = [];
$data = str_replace(' ', '', $data);
$strings = explode(',', $data);
foreach ($strings as $string) {
if (strpos($string, '-') !== false) {
list($start, $end) = explode('-', $string);
if (strlen($end) == 2) {
$end = substr($start, 0, strlen($start) - 2) . $end;
}
$control = 0;
for ($number = $start; $number <= $end; $number++) {
array_push ($contacts, phoneNumberFormat($number));
$control++;
if ($control >= 100) {
break;
}
}
} else {
array_push ($contacts, phoneNumberFormat($string));
}
}
return implode(',', $contacts);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment