-2

I am creating a computation of boardfeet and I want to store all submitted data from a form to an array. I want to do is when I submit the form the data will be saved in an array the when submitted again the data will be added to the array.

I have an array submitted from a form:

  Array
   (
     [0] => Array
     (
        [length] => 5
        [width] => 3
        [height] => 2
     )
    )

I want it to merge with this array.:

   Array
   (
     [0] => Array
     (
        [length] => 3
        [width] => 3
        [height] => 3
     )

    [1] => Array
    (
        [length] => 5
        [width] => 5
        [height] => 5
    )

[2] => Array
    (
        [length] => 5
        [width] => 5
        [height] => 5
    )

 )
6
  • 1
    DID you try anything?? Commented Sep 29, 2016 at 4:51
  • By any chance did you investigate php:array_merge() Commented Sep 29, 2016 at 4:53
  • 1
    Possible duplicate of Array and Associative Array Merge Commented Sep 29, 2016 at 5:01
  • 1
    Instead of dumping your question on this forum you should make some effort and show us your code. We're here to point out your mistake, not give away all the answers. Commented Sep 29, 2016 at 5:02
  • You can use $_SESSION and array_merge() for this. Set the form submitted data in session every time with array_merge() Commented Sep 29, 2016 at 5:03

2 Answers 2

0

try this,

$array2[] =   $array1[0];
print_r($array2);

DEMO

Sign up to request clarification or add additional context in comments.

1 Comment

Please don't entertain such people who are reluctant to make any kind of effort. We are not here to give away all the answers when they are simply going to copy paste without understanding one bit.
0

Try array_merge function like

$merge_array = array_merge($array1,$array2);
print_r($merge_array);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.