【发布时间】:2012-06-13 17:22:29
【问题描述】:
我无法让这段代码正常工作。我需要根据发布的变量获取一个数组。我想这很明显,但我找不到解决方案。
$choice1 =
array (
'order' => array (1,2,3,4,5),
'settings' => (1,0,1)
);
$choice2 =
array (
'order' => array (1,5,3,2,4),
'settings' => (0,0,0)
);
if(isset($_POST['choice'])) {
$template_to_get = $_POST['choice'];
$order_display = $template_to_get['order']; // Here is the problem
echo json_encode(array('order' => $order_display));
}
也试过了:
$order_display = $$template_to_get['order'];
$order_display = "$".$template_to_get['order'];
...
如果我写了这行,它可以工作,但我不知道它是选择 1 还是选择 2 将被发布:
$order_display = $choice1['order'];
我想得到 (1,2,3,4,5) 数组作为输出。 (我简化了,但我有大约 20 个选项X)
谢谢!
【问题讨论】: