title: PHP Array: Twice if statement in a for
body: <p>I'm having a difficult to finish a if statement twice.. The rest works fine but when I try to check in another subarray it doesn't work.</p>
  
  <p><strong>EDIT:</strong> 
  <em>- The first if condition is to check the type of products
  - The second if condition is to check the size attributes.
  - Products: sweatshirt_crianca and sweatshirtc_crianca_capuz 
  - Sizes: 4_anos, 6_anos, 8_anos, 11_anos, 12_anos and 14_anos
  Need to disable ( $this->enabled = false; ) Those sizes except 14_anos.</em></p>
  
  <p>This is what I get from <strong>$order->products[$i]</strong></p>
  
  <pre><code>Array
  (
      [qty] =&gt; 1
      [name] =&gt; .Mr Mickey T-shirt
      [model] =&gt; 
      [image] =&gt; blusa-mr-mrs-blusao-sweat-camisolas-portugal.png
      [tax] =&gt; 20
      [tax_description] =&gt; IVA 23%
      [price] =&gt; 10.8333
      [final_price] =&gt; 16.6666
      [weight] =&gt; 0.00
      [id] =&gt; 1342{18}135{17}132{19}148
      [attributes] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [option] =&gt; s_cor_produto
                      [value] =&gt; branco
                      [option_id] =&gt; 18
                      [value_id] =&gt; 135
                      [prefix] =&gt; +
                      [price] =&gt; 0.0000
                  )
  
              [1] =&gt; Array
                  (
                      [option] =&gt; s_produto
                      [value] =&gt; sweatshirt_crianca
                      [option_id] =&gt; 17
                      [value_id] =&gt; 132
                      [prefix] =&gt; +
                      [price] =&gt; 5.8333
                  )
  
              [2] =&gt; Array
                  (
                      [option] =&gt; s_tamanho_produto
                      [value] =&gt; 8_anos
                      [option_id] =&gt; 19
                      [value_id] =&gt; 148
                      [prefix] =&gt; +
                      [price] =&gt; 0.0000
                  )
  
          )
  
  )
  Array
  (
      [qty] =&gt; 1
      [name] =&gt; Adivinha quem vai ser mama shirt
      [model] =&gt; 
      [image] =&gt; adivinha-quem-vai-ser-mama-tshirt-gravida.png
      [tax] =&gt; 20
      [tax_description] =&gt; IVA 23%
      [price] =&gt; 10.8333
      [final_price] =&gt; 10.8333
      [weight] =&gt; 0.00
      [id] =&gt; 1860{20}157{18}139{17}128{19}152
      [attributes] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [option] =&gt; s_cor_impressao
                      [value] =&gt; branco
                      [option_id] =&gt; 20
                      [value_id] =&gt; 157
                      [prefix] =&gt; +
                      [price] =&gt; 0.0000
                  )
  
              [1] =&gt; Array
                  (
                      [option] =&gt; s_cor_produto
                      [value] =&gt; azul_royal
                      [option_id] =&gt; 18
                      [value_id] =&gt; 139
                      [prefix] =&gt; +
                      [price] =&gt; 0.0000
                  )
  
              [2] =&gt; Array
                  (
                      [option] =&gt; s_produto
                      [value] =&gt; tshirt_mulher
                      [option_id] =&gt; 17
                      [value_id] =&gt; 128
                      [prefix] =&gt; +
                      [price] =&gt; 0.0000
                  )
  
              [3] =&gt; Array
                  (
                      [option] =&gt; s_tamanho_produto
                      [value] =&gt; M
                      [option_id] =&gt; 19
                      [value_id] =&gt; 152
                      [prefix] =&gt; +
                      [price] =&gt; 0.0000
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Sometimes it can contains 1 or 4 subarrays. This is cod payment from osCommerce, I'm trying to exclude specific products from this method based on the attributes of it.
  This works fine in the first if statement to check the [value] but the lines that are commented the syntax is correct but it's not working. This is the code I got:</p>
  
  <pre><code>  for ($i=0, $n=sizeof($order-&gt;products); $i&lt;$n; $i++) {
      if ($order-&gt;products[$i]['weight'] &gt; '0.00') {
        $this-&gt;enabled = false;
      }
      if ( (isset($order-&gt;products[$i]['attributes'])) &amp;&amp; (sizeof($order-&gt;products[$i]['attributes']) &gt; 0) ) {
        for ($j=0, $n2=sizeof($order-&gt;products[$i]['attributes']); $j&lt;$n2; $j++) {
          if ( ($order-&gt;products[$i]['attributes'][$j]['option'] == 's_produto') &amp;&amp; ($order-&gt;products[$i]['attributes'][$j]['value'] == 'sweatshirt_crianca') ) {
            //if ( ($order-&gt;products[$i]['attributes'][$j]['option'] == 's_tamanho_produto') &amp;&amp; ($order-&gt;products[$i]['attributes'][$j]['value'] == '14_anos') ) {
              $this-&gt;enabled = false;
            //}
          }
          else if ( ($order-&gt;products[$i]['attributes'][$j]['option'] == 's_produto') &amp;&amp; ($order-&gt;products[$i]['attributes'][$j]['value'] == 'sweatshirtc_crianca_capuz') ) {
            //if ( ($order-&gt;products[$i]['attributes'][$j]['option'] == 's_tamanho_produto') &amp;&amp; ($order-&gt;products[$i]['attributes'][$j]['value'] != '14_anos') ) {
              $this-&gt;enabled = false;
            //}
          }
        }
      }
    }
  </code></pre>
  
  <p>Any solutions? Thanks.</p>