I don't manage to get this piece of code working. I need to get an array depending of the variable posted. I guess it's obvious but I can't find the slution.
$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));
}
Also tried:
$order_display = $$template_to_get['order'];
$order_display = "$".$template_to_get['order'];
...
If I write this line it works but I don't know if it's choice1 or choice 2 which will be posted:
$order_display = $choice1['order'];
I would like to get the (1,2,3,4,5) array as output. (I simplified but I have around 20 choiceX)
Thanks!