daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. POST variable in array's name php
  2. $choice1 =
  3.     array (
  4.         'order' => array (1,2,3,4,5),
  5.             'settings' => (1,0,1)
  6.     );
  7. $choice2 =
  8.     array (
  9.         'order' => array (1,5,3,2,4),
  10.             'settings' => (0,0,0)
  11.     );
  12. if(isset($_POST['choice'])) {
  13.     $template_to_get = $_POST['choice'];
  14.     $order_display = $template_to_get['order'];          // Here is the problem
  15.     echo json_encode(array('order' => $order_display));
  16. }
  17.    
  18. $order_display = $$template_to_get['order'];
  19. $order_display = "$".$template_to_get['order'];
  20. ...
  21.    
  22. $order_display = $choice1['order'];
  23.    
  24. $choices = array(
  25.     1 => array(
  26.         'order' => array (1,5,3,2,4),
  27.         'settings' => (0,0,0),
  28.     ),
  29.     2 => array(
  30.         'order' => array (1,2,3,4,5),
  31.         'settings' => (1,0,1)
  32.     ),
  33. );
  34.  
  35. if(isset($_POST['choice'])) {
  36.     $template_choice = $_POST['choice'];
  37.     echo json_encode(array('order' => $choices[ $template_choice ]['order'] ));
  38. }
  39.    
  40. $choices = array(
  41.     'template_1' => array( ... );
  42.     ...
  43. );
  44.    
  45. $order_display = $choice1[$_POST['choice']];
  46.    
  47. foreach ($choice as $key => $val)
  48. foreach ($val as $nval)
  49.   echo $key . ' : ' . $nval . '<br />';
  50.    
  51. $varname = 'choice' . $_POST['choice'];
  52. $order_display = $$varname['order'];
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top