title: PHP multidimensional array to variables
body: <p>Ok I am getting info from poloniex API.</p>
  
  <p>It comes back as an array like so:</p>
  
  <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 357988064 [currency] =&gt; DOGE [rate] =&gt; 0.00008000 [amount] =&gt; 3134.03982846 [duration] =&gt; 0.25540000 [interest] =&gt; 0.06403308 [fee] =&gt; -0.00960496 [earned] =&gt; 0.05442812 [open] =&gt; 2017-05-30 23:12:09 [close] =&gt; 2017-05-31 05:19:55 ) [1] =&gt; Array ... and so on
  </code></pre>
  
  <p>Now I am trying to get each element of the array into some sort of variable to use later.</p>
  
  <p>So something like this:</p>
  
  <pre><code>$id=[id] 
  $currency=[currency]
  $rate=[rate]
  $amount=[amount]
  $duration=[duration]
  $interest=interest]
  $fee=fee]
  $earned=[earned]
  $open=[open]
  $close=[close]
  </code></pre>
  
  <p>I want to  put them into a mysqli DB </p>
  
  <p>This is what i am using right now:</p>
  
  <pre><code>if (!$return) {
      echo "No Data";
      print_r($return);
  } else {
      $arrlength=count($return);
      echo "this many results: " .$arrlength. "&lt;br&gt;&lt;br&gt;";
      foreach($return as $x=&gt;$x_value)
        {
  
          echo $return[0][0]. ": Currency: " .$return[0][1]. ". Rate: " .$return[0][2]. " Duration: " .$return[0][3]. " Interest: " .$return[0][4]. " Fee: " .$return[0][5]. " Earned: " .$return[0][6]. " Opened: " .$return[0][7]. " Closed: " .$return[0][8]. "&lt;br&gt;";
  
          //  insert into Database here
        }
  
      // print_r($return);
  }
  </code></pre>
  
  <p>And all it is returning is</p>
  
  <pre><code> : Currency: . Rate: Duration: Interest: Fee: Earned: Opened: Closed:
  </code></pre>
  
  <p>I am a newbie with arrays but i have had success with api's with Json this is 1st  with Arrays.</p>
  
  <p>Been tinkering for a few days with this and i just cant get the right combo</p>
  
  <p>EDIT:
  for anyone who can use this info i went the answer below and to display it on one line i went like this.</p>
  
  <pre><code>if (!$return) {
      echo "No Data";
      //print_r($return);
  } else {
      $arrlength=count($return);
      echo "this many results: " .$arrlength. "&lt;br&gt;&lt;br&gt;";
  
  foreach($return as $x=&gt;$x_value){
      extract($x_value);
      echo $id."   " .$currency."   " .$rate."   " .$duration."   " .$interest."   " .$fee."   " .$earned."   " .strtotime($open)."   " .strtotime($close)."&lt;br&gt;";
      //  insert into Database here
      }
      // print_r($return);
  }
  </code></pre>