Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Simple script to generate a bunch of randomish names, email addresses
* etc. Outputs CSV which can be piped into a file, etc.
*
* Adapt and modify as needed...remember there are more powerful tools out
* there for this sort of thing if you have more complicated needs:
*
* @see https://github.com/fzaninotto/Faker
* @see https://github.com/gevans/phaker
*/
$first_names = [
'Abbas',
'Annabelle',
'Archie',
'Belinda',
'Bruce',
'Davey',
'Donna',
'Edna',
'Edgar',
'Ethelbert',
'Fakhir',
'Fiona',
'Fred',
'Gayle',
'Greg',
'Heidi',
'Henry',
'Ingrid',
'Innis',
'Jabbar',
'Jim',
'Joanne',
'Kareem',
'Karen',
'Kevin',
'Len',
'Lena',
'Martin',
'Melinda',
'Mubarak',
'Nina',
'Norbert',
'Oscar',
'Othella',
'Patricia',
'Paul',
'Qing',
'Quentin',
'Radwan',
'Rachel',
'Sadie',
'Samuel',
'Tabitha',
'Timin',
'Tony',
'Umberto',
'Una',
'Veronica',
'Victor',
'William',
'Wilma',
'Xanthe',
'Xavier',
'Yael',
'Yasmine',
'Zandra',
'Zane',
];
$last_names = [
'Almasi',
'Anderson',
'Brucefield',
'Coleman',
'Dickinson',
'Essa',
'Franco',
'Garcia',
'Hernandez',
'Inglis',
'Jordan',
'Kelly',
'Khan',
'Khoury',
'King',
'Lín',
'Maldonado',
'Nahas',
'Núnez',
'Otherly',
'Phillips',
'Quigley',
'Rodríguez',
'Sandringham',
'Thompson',
'Underhill',
'Veracruz',
'Wasem',
'Wilson',
'Wong',
'Xanderson',
'Xiāo',
'Yule',
'Zhang',
];
$email_providers = [
'grabmail.fake.info',
'instapost.test.email',
'offline.simulated.net',
'pretend.user.web',
'quickimail.interwebs',
'test.example.com',
];
$roles = [
'subscriber',
'contributor',
'administrator',
];
shuffle( $first_names );
shuffle( $last_names );
$out = [];
while ( count( $out ) < 50 ) {
if ( ! next( $first_names ) ) {
shuffle( $first_names );
reset( $first_names );
}
if ( ! next( $last_names ) ) {
shuffle( $last_names );
reset( $last_names );
}
$first_name = current( $first_names );
$last_name = current( $last_names );
$possible_name = "$first_name $last_name";
if ( isset( $out[ $possible_name ] ) ) {
continue;
}
$slug = str_replace( ' ', '-', strtolower( $possible_name ) );
$email_provider = $email_providers[ array_rand( $email_providers ) ];
$out[ $possible_name ] = [
'username' => "{$slug}_test_user",
'email' => "{$slug}@{$email_provider}",
'role' => $roles[ array_rand( $roles ) ],
];
}
foreach ( $out as $name => $property ) {
print "{$name},{$property['username']},{$property['email']},{$property['role']}\n";
}
@barryhughes

This comment has been minimized.

Copy link
Owner Author

commented May 25, 2019

Sample use:

php 50-fake-users-as-csv.php > my-user-list.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.