title: Find key in array in a foreach
body: <p>I have this foreach function:</p>
  
  <pre><code>foreach($total_data as $arrays){        
  
                  //debug
                  //print_r($total_data);
                  //exit;
  
                  if($arrays['code']=='d_payment_fee'){
                      $dpaymentfeetext = ' - '.$arrays['title'];
                      $dpaymentfeevalue = $arrays['value']/1.20;
                  }
  
                  if($arrays['code']=='shipping'){
  
                              $api-&gt;addItem(array( 
                                      'name' =&gt; $arrays['title'].$dpaymentfeetext,
                                      'quantity' =&gt; 1,
                                      'unit' =&gt; 'ks',
                                      'unit_price' =&gt; ($arrays['value']+$dpaymentfeevalue)*1.20
                              ));
                      }
              }        
  </code></pre>
  
  <p>This works fine, if the first array item is the d_payment_fee, and the second is the shipping:</p>
  
  <pre><code>[0] =&gt; Array
      (
          [order_total_id] =&gt; 214950
          [order_id] =&gt; 4779
          [code] =&gt; d_payment_fee
          [title] =&gt; COD
          [text] =&gt; 1,00€
          [value] =&gt; 1.0000
          [sort_order] =&gt; 2
      )
  
  [1] =&gt; Array
      (
          [order_total_id] =&gt; 214951
          [order_id] =&gt; 4779
          [code] =&gt; shipping
          [title] =&gt; Free
          [text] =&gt; 0,00€
          [value] =&gt; 0.0000
          [sort_order] =&gt; 3
      )
  </code></pre>
  
  <p>There are cases when <strong>d_payment_fee</strong> is not on the first place, like here:</p>
  
  <pre><code>[0] =&gt; Array
          (
              [order_total_id] =&gt; 216352
              [order_id] =&gt; 4796
              [code] =&gt; shipping
              [title] =&gt; Free shipping
              [text] =&gt; 2,50€
              [value] =&gt; 2.5000
              [sort_order] =&gt; 2
          )
  
      [1] =&gt; Array
          (
              [order_total_id] =&gt; 216353
              [order_id] =&gt; 4796
              [code] =&gt; d_payment_fee
              [title] =&gt; COD
              [text] =&gt; 1,00€
              [value] =&gt; 1.0000
              [sort_order] =&gt; 3
          )
  </code></pre>
  
  <p>In this case I got undefined variable $dpaymentfee*.
  Can we find the <strong>d_payment_fee</strong> if it is not on the first place?</p>