title: PHP Laravel 5.5 collections flatten and keep the integer keys?
body: <p>I have the following array :</p>
  
  <pre><code>$array = [
      '2' =&gt; ['3' =&gt; ['56' =&gt; '2'], '6' =&gt; ['48' =&gt; '2']],
      '4' =&gt; ['4' =&gt; ['433' =&gt; '2', '140' =&gt; '2'], '8' =&gt; ['421' =&gt; '2', '140' =&gt; '2']],
      '5' =&gt; ['5' =&gt; ['88' =&gt; '4', '87' =&gt; '2']]
  ];
  </code></pre>
  
  <p>The following code (flattening) should return it by preserving keys, but it doesnt?</p>
  
  <pre><code>collect($array)-&gt;flatten(1);
  </code></pre>
  
  <p>should give me </p>
  
  <pre><code>[
      '3' =&gt; ['56' =&gt; '2'],
      '6' =&gt; ['48' =&gt; '2'],
      '4' =&gt; ['433' =&gt; '2', '140' =&gt; '2'],
      '8' =&gt; ['421' =&gt; '2', '140' =&gt; '2'],
      '5' =&gt; ['88' =&gt; '4', '87' =&gt; '2']
  ]
  </code></pre>
  
  <p>However it loses the keys, and just gives array results :/
  Am I using it wrong? How should I flatten and preserve keys?</p>