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
)
)