if 문을 두 번 완료하는 데 어려움이 있습니다. 나머지는 잘 작동하지만 다른 하위 배열을 체크인하려고하면 작동하지 않습니다.PHP 배열 : for :
편집 : - 조건이 크기 속성을 확인하는 경우, 둘째 - 조건이 제품 의 종류를 확인하는 경우 첫 번째. - 제품 : sweatshirt_crianca 및 sweatshirtc_crianca_capuz - 크기 : 4_anos, 6_anos, 8_anos, 11_anos, 12_anos 및 14_anos 해제해야합니다 ($ this-> enabled = false;) 14_anos를 제외한 크기입니다.
이 내가 $ 순서 -> 제품 [$ i]를
Array
(
[qty] => 1
[name] => .Mr Mickey T-shirt
[model] =>
[image] => blusa-mr-mrs-blusao-sweat-camisolas-portugal.png
[tax] => 20
[tax_description] => IVA 23%
[price] => 10.8333
[final_price] => 16.6666
[weight] => 0.00
[id] => 1342{18}135{17}132{19}148
[attributes] => Array
(
[0] => Array
(
[option] => s_cor_produto
[value] => branco
[option_id] => 18
[value_id] => 135
[prefix] => +
[price] => 0.0000
)
[1] => Array
(
[option] => s_produto
[value] => sweatshirt_crianca
[option_id] => 17
[value_id] => 132
[prefix] => +
[price] => 5.8333
)
[2] => Array
(
[option] => s_tamanho_produto
[value] => 8_anos
[option_id] => 19
[value_id] => 148
[prefix] => +
[price] => 0.0000
)
)
)
Array
(
[qty] => 1
[name] => Adivinha quem vai ser mama shirt
[model] =>
[image] => adivinha-quem-vai-ser-mama-tshirt-gravida.png
[tax] => 20
[tax_description] => IVA 23%
[price] => 10.8333
[final_price] => 10.8333
[weight] => 0.00
[id] => 1860{20}157{18}139{17}128{19}152
[attributes] => Array
(
[0] => Array
(
[option] => s_cor_impressao
[value] => branco
[option_id] => 20
[value_id] => 157
[prefix] => +
[price] => 0.0000
)
[1] => Array
(
[option] => s_cor_produto
[value] => azul_royal
[option_id] => 18
[value_id] => 139
[prefix] => +
[price] => 0.0000
)
[2] => Array
(
[option] => s_produto
[value] => tshirt_mulher
[option_id] => 17
[value_id] => 128
[prefix] => +
[price] => 0.0000
)
[3] => Array
(
[option] => s_tamanho_produto
[value] => M
[option_id] => 19
[value_id] => 152
[prefix] => +
[price] => 0.0000
)
)
)
때때로 할 수있는 1 개 또는 4 하위 어레이를 포함에서 무엇을 얻을 수 있습니다. 이것은 osCommerce의 대구 지불입니다. 나는이 속성의 속성에 따라이 메소드에서 특정 제품을 제외하려고합니다. [값]을 확인하는 첫 번째 if 문에서 올바르게 작동하지만 구문에 주석이있는 행은 정확하지만 작동하지 않습니다. 이것은 내가 가지고있는 코드입니다 :
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
if ($order->products[$i]['weight'] > '0.00') {
$this->enabled = false;
}
if ((isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0)) {
for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
if (($order->products[$i]['attributes'][$j]['option'] == 's_produto') && ($order->products[$i]['attributes'][$j]['value'] == 'sweatshirt_crianca')) {
//if (($order->products[$i]['attributes'][$j]['option'] == 's_tamanho_produto') && ($order->products[$i]['attributes'][$j]['value'] == '14_anos')) {
$this->enabled = false;
//}
}
else if (($order->products[$i]['attributes'][$j]['option'] == 's_produto') && ($order->products[$i]['attributes'][$j]['value'] == 'sweatshirtc_crianca_capuz')) {
//if (($order->products[$i]['attributes'][$j]['option'] == 's_tamanho_produto') && ($order->products[$i]['attributes'][$j]['value'] != '14_anos')) {
$this->enabled = false;
//}
}
}
}
}
모든 솔루션? 감사.
는 그 주석'if's은 다른 사람 안에 있어야하고 있습니까? A = B인지 테스트 중이니까. 그렇다면 A = C인지 테스트합니다. 물론 그렇지 않습니다. – sidyll
글쎄,이 속성들 중 어느 것도이 두 조건을 모두 통과하지 못하는 것 같습니다 (한 번 주석 처리되지 않은 상태). 네가 가지고있는 것처럼 그들이 중첩되어 있다고 확신합니까? – segFault
논리가 의미가 없습니다. 어쩌면 우리가 당신의 논리를 의사 코드로 제공하여 우리가 무엇을 성취하려고하는지 알 수 있습니다. – CodeGodie