0

I have an array like below:

$storedItem = [
    'item_id' => $ItemInfo['ItemId'],
    'qty' => [],
    'price' => $item->price,
    'size' => [],
    'produ' => [],
    'item' => $item
];

I have 2 string variables called $size and $quantity.

I need to push them into produ array. Then I used

> array_push($storedItem['produ'], $size);

But, the thing is I need to push $size and $quantity several times into produ array. But, when I use array_push again & again, it overwrite the array.

But, what I want like below.

$storedItem['produ'] = [
    0 => [0 => $size, 1 => $quantity],
    1 => [0 => $size, 1 => $quantity],
    2 => [0 => $size, 1 => $quantity]
];

How can I do like this?

0

1 Answer 1

1

Maybe this solve your problem:

$storedItem['produ'][] = [$size, $quantity];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.