title: How to retrieve value from pdo array
body: <p>I am trying to get the value for total from this array to put into a variable:</p>
  
  <pre><code>Array ( 
  
  [0] =&gt; Array ( [Variable_name] =&gt; var1 [Value] =&gt; 2 ) 
  [1] =&gt; Array ( [Variable_name] =&gt; total [Value] =&gt; 1 ) 
  [2] =&gt; Array ( [Variable_name] =&gt; var3 [Value] =&gt; 0.002 ) 
  
  )
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>$data = $array-&gt;fetchAll(PDO::FETCH_ASSOC);
  
  echo $data[1]['total'];
  
  foreach ($data as $result){
       echo $result['total'];
  }
  
  foreach ($data as $result){
       echo $result[1]['total'];
  }
  </code></pre>
  
  <p>None of the above echo the variable, if I use <code>print_r($array-&gt;fetchAll(PDO::FETCH_ASSOC));</code> it prints the array, what is the correct way to do this?</p>
  
  <p>In short: I want to get the value from the key <code>Value</code>, where the <code>Variable_name</code> is holding the value <code>total</code>. Here in this example it would be 1.</p>