我需要生成n ( $size_of_list
) 个名称的列表...可能的成员在数组 ( $names_list
) 中给出,它给出了名称和该名称出现的机会。所以它是一个包含 40 个字符串和整数数组的数组:
$names_list = array (
0 => array ('name' => "Mike", 'frequency' => 8),
1 => array ('name' => "Jane", 'frequency' => 7),
2 => array ('name' => "Leopold", 'frequency' => 1),
3 => array ('name' => "George", 'frequency' => 5),
...
39 => array ('name' => "Mark", 'frequency' => 6)
)
$names_list[0] = array('name' => "Mike", 'frequency' => 8)
意味着 $name="Mike" 的 $frequency(或机会)为 8,而 "Leopold" 的机会值为 1 - 出现的机会很小...