title: export an excel with dynamic array in laravel using maatwebsite
body: <p>I would like to export Excel in Laravel version 5.7. I am using package Maatwebsite Laravel Excel version 3.1. I have an array of persons' information like this:</p>
  
  <pre><code> $persons = {
          "person 1": [
              {
                  "answer1": "shokouh"
              },
              {
                  "answer2": "dareshiri"
              },
              {
                  "answerN": "answer N"
              }
          ],
  ...
          "person M ": [
              {
                  "answer1": "sarah"
              },
              {
                  "answer2": "smith"
              },
              {
                  "answerN": "answer N"
              }
          ]
      }
  </code></pre>
  
  <p>and I wanna to export that in such as below excel:</p>
  
  <pre><code>Person 1    Answer 1    Answer 2    …   Answer N
  Person M    Answer M2   Answer M2   …   Answer MN
  </code></pre>
  
  <p>This is my export function in Controller:</p>
  
  <pre><code>public function export(Request $request, Tournament $tournament) {
  
      ... 
  
      $persons;
  
      return Excel::download(new ParticipantExport($persons), 'personInformation.xlsx');
  }
  </code></pre>
  
  <p>This is my participantExport in app\Export\participantExport:</p>
  
  <pre><code>class participantExport implements FromArray
  {
      protected $invoices;
  
      public function __construct(array $invoices)
      {
          $this-&gt;invoices = $invoices;
      }
  
      public function array(): array
      {
          return $this-&gt;invoices;
      }
  }
  </code></pre>
  
  <p>any body can help me?</p>