PHP - Trying to create an array seems to not work
<p>This is the code:</p>

<pre><code>function create_order_with_custom_products()
{
    $orderGenerator = new OrderGenerator();
    $orderGenerator-&gt;setCustomer(6907);

    $orderGenerator-&gt;createOrder(array(
        // Add configurable product
        array(
            'product' =&gt; 30151,
            'qty' =&gt; 1
        ), array(
            'product' =&gt; 30150,
            'qty' =&gt; 2
        ),
    ));
}
</code></pre>

<p>I have to create array with such structure:</p>

<pre><code>        array(
            'product' =&gt; 30151,
            'qty' =&gt; 1
        ), array(
            'product' =&gt; 30150,
            'qty' =&gt; 2
        ),
</code></pre>

<p>I am trying to create an array with same structure like that:</p>

<pre><code>foreach($ItemsInCart['productid'] as $key=&gt;$value){
    $ProductId = $value;
    $ProductQty = $ItemsInCart["productqty"][$key];
    $product_id = $ProductId; // Replace id with your product id
    $qty = $ProductQty; // Replace qty with your qty

    $ItemsId[] = ['product' =&gt; $ProductId, 'qty' =&gt; $ProductQty];
}
</code></pre>

<p>This gives me result of:</p>

<blockquote>
  <p>Array ( [0] => Array ( [product] => 30143 [qty] => 1 ) [1] => Array (
  [product] => 30144 [qty] => 2 ) [2] => Array ( [product] => 30145
  [qty] => 3 ) [3] => Array ( [product] => 30146 [qty] => 4 ) [4] =>
  Array ( [product] => 30147 [qty] => 5 ) )</p>
</blockquote>

<p>All i want to know is why this :</p>

<pre><code>function create_order_with_custom_products()
{
    $orderGenerator = new OrderGenerator();
    $orderGenerator-&gt;setCustomer(6907);

    $orderGenerator-&gt;createOrder(array(
        // Add configurable product
        array(
            'product' =&gt; 30151,
            'qty' =&gt; 1
        ), array(
            'product' =&gt; 30150,
            'qty' =&gt; 2
        ),
    ));
}
</code></pre>

<p>Is not the same as this:</p>

<pre><code>function create_order_with_custom_products()
{
    $orderGenerator = new OrderGenerator();
    $orderGenerator-&gt;setCustomer(6907);

    $orderGenerator-&gt;createOrder(array($ItemsId));
}
</code></pre>

<p>Why the second approach is not working, where is my mistake?</p>