0
我会再做连接的foreach循环并连接同一阵列
Foreach (item as $orderitem) {
//for each item I have to get the array below
$prodord[] .= array(
'variant_id' => $variant_id,
'quantity' => 2
);
$orderData = array('order' => array(
'line_items' => array(
//the following variable is when I need to put the array if is one item
//or two arrays if are two item
$prodord
/*array(
'variant_id' => $variant_id,
'quantity' => 1
)*/
)
));
我试图以连接阵列内部变量数组有一个变量值,这样
//First item
array(
'variant_id' => 123456,
'quantity' => 1
),
//2d item
array(
'variant_id' => 654321,
'quantity' => 1
)
但我输出看起来像
array(2) {
[0]=>
string(5) "Array"
[1]=>
string(5) "Array"
}
有一个项目,它的作品完美。
只要忘记点''',就是字符串连接:'$ prodord [] = array(.........'']'语法创建一个新的数组元素。 – AbraCadaver