Skip to content

Instantly share code, notes, and snippets.

@muya
Last active October 8, 2020 16:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muya/d44dd3d379bcdef175cf to your computer and use it in GitHub Desktop.
Save muya/d44dd3d379bcdef175cf to your computer and use it in GitHub Desktop.
Code for creating random Safaricom Kenya Phone numbers (accompanying blog post: https://blog.muya.co.ke/random-safaricom-kenya-phone-numbers/)
<?php
// include Faker in your project (https://github.com/fzaninotto/Faker#installation)
use Faker\Factory as Faker;
$faker = Faker::create();
$regex = "/(\+?254|0){1}[7]{1}([0-2]{1}[0-9]{1}|[9]{1}[0-2]{1})[0-9]{6}/";
$samplePhoneNumber = $faker->regexify($regex);
echo $samplePhoneNumber . "\n";
@peter010
Copy link

peter010 commented Apr 6, 2017

How do I create a phone number am confused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment