Skip to content

Instantly share code, notes, and snippets.

@YavorK
Last active October 19, 2016 04:46
Show Gist options
  • Save YavorK/f91780cd29a290fd7b9846f97ab8cf17 to your computer and use it in GitHub Desktop.
Save YavorK/f91780cd29a290fd7b9846f97ab8cf17 to your computer and use it in GitHub Desktop.
Generate names with faker (fzaninotto/faker)
<?php
// this script uses https://github.com/fzaninotto/Faker
// to generate male/female names:
require 'vendor/autoload.php';
// use the factory to create a Faker\Generator instance
$faker = Faker\Factory::create();
// generate data by accessing properties
$maleNames = [];
for ($i = 0; $i < 100; $i++) {
$maleNames[] = $faker->name('male');
}
echo '<?php'.PHP_EOL;
echo PHP_EOL;
echo '$maleNames = ';
var_export($maleNames);
echo ';';
$femaleNames = [];
for ($i = 0; $i < 100; $i++) {
$femaleNames[] = $faker->name('female');
}
echo PHP_EOL;
echo PHP_EOL;
echo '$femaleNames = ';
var_export($femaleNames);
echo ';';
@YavorK
Copy link
Author

YavorK commented Oct 19, 2016

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