PHP 类能够生成数百万个随机名称组合(名字和姓氏),用作应用程序和其他项目中的演示数据。
PHP 5.3+
将 php-random-name-generator 文件夹上传到您所需的位置并包含该类:
include 'php-random-name-generator/randomNameGenerator.php';
启动类并设置输出格式。可用的输出格式为“array”、“associative_array”和“json”。如果未指定输出,则将使用数组。请参阅下面的每个示例输出。
$r = new randomNameGenerator('array');
通过传递要创建的名称数量来生成名称:
$names = $r->generateNames(10);
现在您可以迭代数据并创建用户帐户或用它做任何您想做的事情(不要作恶)。
[
{
"first_name": "Fernande",
"last_name": "Hauer"
},
{
"first_name": "Erlinda",
"last_name": "Thiel"
},
{
"first_name": "Elena",
"last_name": "Soleman"
},
{
"first_name": "Hiroko",
"last_name": "Froncillo"
},
{
"first_name": "Jordon",
"last_name": "Buehring"
},
{
"first_name": "Verlie",
"last_name": "Coelho"
},
{
"first_name": "Amos",
"last_name": "Wernecke"
},
{
"first_name": "Chasidy",
"last_name": "Jaskolski"
},
{
"first_name": "Dollie",
"last_name": "Estrem"
},
{
"first_name": "Noma",
"last_name": "Mends"
}
]
Array
(
[0] => Stacee Scheiderer
[1] => Ambrose Sens
[2] => Quinton Spratte
[3] => Jolie Kapsalis
[4] => Barbra Krawiec
[5] => Phylicia Eikmeier
[6] => Walton Chalfin
[7] => Letha Prakash
[8] => Tu Grenke
[9] => Brunilda Kirstein
)
Array
(
[0] => Array
(
[first_name] => Annabel
[last_name] => Mapa
)
[1] => Array
(
[first_name] => Claire
[last_name] => Iovino
)
[2] => Array
(
[first_name] => Agripina
[last_name] => Gillig
)
[3] => Array
(
[first_name] => Kathern
[last_name] => Strausbaugh
)
[4] => Array
(
[first_name] => Delbert
[last_name] => Whitescarver
)
[5] => Array
(
[first_name] => Marlon
[last_name] => Botz
)
[6] => Array
(
[first_name] => Patrice
[last_name] => Baller
)
[7] => Array
(
[first_name] => Teodora
[last_name] => Semmes
)
[8] => Array
(
[first_name] => Billy
[last_name] => Hruby
)
[9] => Array
(
[first_name] => Sammy
[last_name] => Hess
)
)