title: assign different variable name for $_POST
body: <p>I would like to give incrementing variable name to each post value and take the assigned variable and build array. The below is what I tried</p>
  
  <pre><code>$list = array();
  $x = 0;
  $prefix = '$var_';
  
  foreach(array_slice($_POST, 1) as $test){
     $x++;
     $list[] = "{$prefix}{$x} = {$test};":
  }
  
  echo implode("  ", $list);
  </code></pre>
  
  <p>So if I had 4 values in the post, like <code>0, a, b, c</code> it would echo something like</p>
  
  <pre><code>$var_1 = a;  $var_2 = b;  $var_3 = c;
  </code></pre>
  
  <p>I would like to put all the three $vars in array like below and use their value. This is where I am stuck. Any help?</p>
  
  <pre><code>$vars = array($var_1, $var_2, $var_3)
  </code></pre>
  
  <p>What I'm trying to achieve is to insert dynamic data to table where I only know the table_name,</p>
  
  <pre><code> $stmt = $mydb-&gt;prepare($sql);//I am able to populate the $sql and $str
   $stmt-&gt;bind_param($str, $vars);
   $stmt-&gt;execute();
  </code></pre>