Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- POST variable in array's name php
- $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'];
- ...
- $order_display = $choice1['order'];
- $choices = array(
- 1 => array(
- 'order' => array (1,5,3,2,4),
- 'settings' => (0,0,0),
- ),
- 2 => array(
- 'order' => array (1,2,3,4,5),
- 'settings' => (1,0,1)
- ),
- );
- if(isset($_POST['choice'])) {
- $template_choice = $_POST['choice'];
- echo json_encode(array('order' => $choices[ $template_choice ]['order'] ));
- }
- $choices = array(
- 'template_1' => array( ... );
- ...
- );
- $order_display = $choice1[$_POST['choice']];
- foreach ($choice as $key => $val)
- foreach ($val as $nval)
- echo $key . ' : ' . $nval . '<br />';
- $varname = 'choice' . $_POST['choice'];
- $order_display = $$varname['order'];
Add Comment
Please, Sign In to add comment