DEV Community

loading...

Discussion on: Daily Challenge #9 - What's Your Number?

Collapse
peter279k profile image
peter279k

Here is the simple solution with PHP:

function createPhoneNumber($numbersArray) {
    $format = "(%s%s%s) %s%s%s-%s%s%s%s";

    return sprintf(
      $format,
      $numbersArray[0], $numbersArray[1], $numbersArray[2], $numbersArray[3],
      $numbersArray[4], $numbersArray[5], $numbersArray[6], $numbersArray[7],
      $numbersArray[8], $numbersArray[9]
    );
}