根據一個人的姓氏隨機生成幾個人的名字
$name5= mb_substr('袁斯強', 0,1,'utf-8'); $ab=array("忠","少","小","斯","欽","義","仁","泉","仕","國","廣","良","早","春","和","尚","節","高","祥","文","方","應","屯","旭","浪","宇","信","本","毛"); $ab2=array("華","毛","德","平","清","輝","強","雲","保","坤","發","貴","水","如","元","貴","榮","根","亮","才","新","成","洪","慶","勇","財","進","斌","彬","兵"); $rand_keys1 = array_rand($ab,2); $rand_keys2 = array_rand($ab2,2); $rand_keys3 = array_rand($ab,2); $rand_keys4 = array_rand($ab2,2); $rand_keys5 = array_rand($ab,2); $rand_keys6 = array_rand($ab2,2); $rand_keys7 = array_rand($ab,2); $rand_keys8 = array_rand($ab2,2); $name1= $name5.$ab[$rand_keys1[0]].$ab2[$rand_keys2[1]]; $name2= $name5.$ab[$rand_keys3[1]].$ab2[$rand_keys4[0]]; $name3= $name5.$ab[$rand_keys5[0]].$ab2[$rand_keys6[1]]; $name4= $name5.$ab[$rand_keys7[1]].$ab2[$rand_keys8[0]]; echo $name1."</p>".$name2."</p>".$name3."</p>".$name4;