【发布时间】:2021-04-07 14:21:19
【问题描述】:
希望你能帮助我..
我有这个简单的代码:
foreach ($by_sellers as $seller_id => $info) {
print_r($info);
echo 'AMOUNT : ' . $info['total'] .'; STORE : '. $info['name'];
}
输出是这样的:
Array(
['total'] => 100
['name'] => 'Store Name'
)
AMOUNT : ; STORE :
这真的很奇怪,因为如果单独完成,我无法读取变量的值,但它会显示在 var_dump 和 print_r 上。这些数据来自输入表单。
<input name="by_sellers[1]['total']" value="100">
<input name="by_sellers[1]['name']" value="Store Name">
希望有人能解决这个问题..thanx..
【问题讨论】:
-
Cannot reproduce。这必须比你所展示的更多。您能否提供
$by_sellers的样本? -
也许你的名字在你的输入中是错误的?您没有使用 php 标签或将其列为带有 $ 的变量,因此您的 'name' 将直接为 'by_sellers[1]['total']' 而不是的值
-
啊,我花了一些时间赶上。定义索引时不应在 HTML 中使用单引号,否则它将成为索引的一部分。将
by_sellers[1]['total']更改为by_sellers[1][total],其他任何人都一样。 -
@El_Vanja thanx .. 在阅读您的评论之前我已经找到它了.. 呵呵..
标签: php forms loops variables post