Very stupid question, but still. Is it possible to combine multiple arrays under one variable?
For example:
$a = [1, 2, 3]; $b = [4, 5, 6];
So that eventually came out:
$c = [1, 2, 3], [4, 5, 6];

  • $c = [$a, $b] ? - xEdelweiss
  • So $c = [1, 2, 3], [4, 5, 6]; It will not work, but it will come out as in the comment above .. - entithat
  • @xEdelweiss I work with a very harmful api, and he doesn’t want to accept this, he needs unencrypted arrays

2 answers 2

If you do this: $c = [$a, $b]; then we get $c = [[1, 2, 3], [4, 5, 6]];

You can still get not two nested arrays, but one common one, like this: $c = array_merge($a, $b); . We get $c = [1, 2, 3, 4, 5, 6];

    You can, using a double array:

     $c = [$a, $b]