print_r($_POST['Receipt']['name'])
给了我一个像这样的数组
Array (
[Donations] => Array (
[name] => Donations
)
[Fees] => Array (
[ledger] => Fees
)
[100] => Array (
[amount] => 100
)
[Others] => Array (
[name] => Others
)
)
这里两个重复的数值100和费用(它们分别是字段数量和分类帐的值)是我想要存储在数组中的值。我试过这样的事情
foreach ($_POST['Receipt']['name'] as $item)
{
if (isset($item['amount']))
{
$amount[]= $item['amount'];
}
if (isset($item['ledger']))
{
$ledger[]= $item['ledger'];
}
}
但$ ledger []和$ amount []不会存储它们的重复值。对于amounnt [],它只存储[amount] => 100
中的100并且不会将{100}存储在[100] => Array
中如何将重复值存储在此数组中?
答案 0 :(得分:0)
试试这个
foreach ($_POST['Receipt']['name'] as $item)
{
if (isset($item['100']))
{
$amount[]= $item['100']['amount'];
}
if (isset($item['fees']))
{
$ledger[]= $item['fees']['ledger'];
}
}