<?php
$name_array = [
'服务员',
'收银员',
'备菜',
'后厨',
'领班',
'迎送员',
'跑菜员',
'火头主管',
'砧板主管',
'上什主管',
'凉菜中工',
'面点中工',
'火头中工',
'厨师长',
'明档',
'切菜',
'炒锅',
'切配打荷',
'洗碗勤杂',
'大厅经理',
'接待',
'营业主管',
'行政文员',
'点菜员',
'收银员',
];
$content = file("./name.txt");
$rand_words = [];
foreach ($content as $key => $item){
if (empty($rand_words)){
$rand_words = array_rand(array_flip($name_array), 7);
}
if (mb_strpos($item, "服务员") !== false){
$replace_word = array_pop($rand_words);
$content[$key] = mb_ereg_replace("服务员", $replace_word, $item);
}
}
file_put_contents("rand_name.txt", implode("", $content));