【发布时间】:2015-11-19 01:34:37
【问题描述】:
$users = [
"Andrew",
"Max",
"Larry",
"Ricardo",
"Lucy",
"Marcus",
"Sophie"
];
$sector_rel = [];
$location_rel = [];
function sectorRel($user){
return sector_rel[] = round(1/rand(1,10),3);
}
function locationRel($user){
return $location_rel[] = round(1/rand(1,20),3);
}
foreach($users as $user){
sectorRel($user);
locationRel($user);
}
【问题讨论】:
-
您需要细化您的问题。你想做什么?
-
你遇到了什么问题?
-
寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为和特定的问题或错误。
-
$sector_rel和$location_rel在 for 循环结束后不会被填充(如果这是您所期望的),因为它们在全局范围内