PHP code example of jfrk / swedish-phone-formatter
1. Go to this page and download the library: Download jfrk/swedish-phone-formatter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jfrk / swedish-phone-formatter example snippets
use SwedishPhoneFormatter\SwedishPhoneFormatter;
$formatter = new SwedishPhoneFormatter();
$formatter->format('081234567'); // '08-123 45 67'
// Changes the area code separator
$formatter->format('081234567', ' '); // '08 123 45 67'
// Changes the area code and number separators
$formatter->format('081234567', '-', ''); // '08-1234567'
// Removes +46 country prefix and extension numbers
$formatter->format('+46 (0) 81234567'); // '08-123 45 67'
// Doesn’t try to format foreign numbers
$formatter->format('+1-202-555-0144'); // '+1-202-555-0144'
// Doesnt’t try to format non-formattable strings
$formatter->format('foobar'); // 'foobar'
// Supports number grouping for numbers without area codes
$formatter->format('112'); // '112'
$formatter->format('1177'); // '1177'
$formatter->format('11414'); // '114 14'
$formatter->format('123 456'); // '12 34 56'
$formatter->format('1234567'); // '123 45 67'
$formatter->format('12345678'); // '123 456 78'