-2

我有一个周期,而:

while ($userEquipments = mysql_fetch_array($getUserEquipments))

并且在这个循环中有一个带有数组的 if:

if ($userEquipments['cloth_id'] == $clothes['id'] && $userEquipments['cloth_is_used'] == 1)
            $isUsed = array('cloth_type' => $clothes['type_cloth'], 'cloth_name' => $clothes['name'], 'cloth_image' => $clothes['image']);

我的问题是如何返回这个数组中的所有信息?

4

1 回答 1

0

您应该在 while 之外声明您的数组,这样您就可以在循环之外访问它。

尝试这个:

$isUsed[];

while ($userEquipments = mysql_fetch_array($getUserEquipments))
{
    if ($userEquipments['cloth_id'] == $clothes['id'] && $userEquipments['cloth_is_used'] == 1)
    {
        $isUsed['cloth_type'] =  $clothes['type_cloth'];
        $isUsed['cloth_name'] =  $clothes['name'];
        ...
        break;
    }
}

// Print the array
print_r($isUsed);
于 2012-05-19T11:47:40.143 回答