문제 : print_r의 경우 PHP 다차원 배열 (비틀림 일부 뇌)
$productArray[] = array(); foreach ($order->getAllItems() as $item) { $productArray[] = array( "product" => $item->getName(), "qty" => $item->getQtyOrdered(), "amount" => $item->getPrice(), ); }
이
이 값만큼 내가 모델 클래스에 저장 될 수 있습니다 젠토에서 변수를 얻을 $ productArray []출력 예제 1 :
array(1) {
[0]=>
array(3) {
["product_name"]=>
string(12) "Test Product"
["product_qty"]=>
string(6) "2.0000"
["product_price"]=>
string(7) "12.0000"
}
}
012,351 6,샘플 출력 2 :
array(2) {
[0]=>
array(3) {
["product_name"]=>
string(12) "Test Product"
["product_qty"]=>
string(6) "2.0000"
["product_price"]=>
string(7) "12.0000"
}
[1]=>
array(3) {
["product_name"]=>
string(6) "Test 2"
["product_qty"]=>
string(6) "5.0000"
["product_price"]=>
string(7) "22.0000"
}
}
그리고이처럼 만들 수있는 방법 (이런 식으로 인쇄되어야한다)
경우, 출력 1 : 최종 출력 1
<input type="hidden" name="product" value="Test Product" />
<input type="hidden" name="amount" value="24.00" />
출력 2 : 최종 출력 2
<input type="hidden" name="product1" value="Test Product" />
<input type="hidden" name="amount1" value="24.00" />
<input type="hidden" name="product2" value="Test 2" />
<input type="hidden" name="amount2" value="110.00" />
는 재미 :)이는 더미 문제가 을 가지고 있지만, 다른 사람 이 같이양 값은 PRODUCT_PRICE * product_qty에서 얻을 수 있습니다.
+1 당신은 저를 때려 눕 힙니다. ;) – DondeEstaMiCulo
hahahaha ... 이것은 도움이된다! – Jorge