Skip to content

Instantly share code, notes, and snippets.

@cygeorgel
Created February 19, 2020 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cygeorgel/6fb496c1236686423cc2aefc0092222d to your computer and use it in GitHub Desktop.
Save cygeorgel/6fb496c1236686423cc2aefc0092222d to your computer and use it in GitHub Desktop.
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));
}
}
// // test
//
// print_r ($contacts);
//
// dd (count($contacts) . ' contacts added');
return $contacts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment