当我创建另一个foreach(second)并将第一个foreach传递给第二个foreach时,我正在处理一个foreach(first),它在数据中提供了完整的数组。第一个foreach的第一个值从未出现在第二个foreach中。有谁知道为什么foreach会这样表现?有解决方案吗?
我以这种方式尝试了运气
$userIdsPerRoom = chatRoomUsersId($_SESSION['currentRoomID']);
foreach ($userIdsPerRoom as $value) {
$list[] =$value['UserID'];
}
foreach ($list as $value) {
$userInfo = chatRoomUsersEmail($value);
foreach ($userInfo as $info) {
echo $info['userEmail'];
}
}
echo count($list); ///gives the full list
}
我用这段代码注意到了
$userIdsPerRoom = chatRoomUsersId($_SESSION['currentRoomID']); //return an array of intergers with five values example array(1,2,3,4,5)
foreach ($userIdsPerRoom as $value){
$userInfo = chatRoomUsersEmail($value['UserID']);
foreach ($userInfo as $info){
echo $info['userEmail']; /// I only get four values example array(b,c,d,e)
}
}