title: Export multidimensional array in excel or csv in laravel
body: <p>Really it's complicated situation for me right now.</p>
  
  <p>Here I have to export multidimensional array data into excel which is looks like below image, but I'm unable to make it possible.</p>
  
  <p>Please help me to export the multidimensional array data to export in excel.</p>
  
  <p>I have an array from relational query like:</p>
  
  <pre><code>$array = [
      0 =&gt; [
          'name' =&gt; 'Devat Karetha',
      ],
      1 =&gt; [
          'name' =&gt; 'John Doe',
          'schools' =&gt; [
              0 =&gt; [
                  'school_name' =&gt; 'ABC School',
                  'school_address' =&gt; 'ABC Address',
              ],
              1 =&gt; [
                  'school_name' =&gt; 'XYZ School',
                  'school_address' =&gt; 'XYZ Address',
              ]
          ],
          'sports' =&gt; [
              0 =&gt; [
                  'id' =&gt; 8,
                  'sport_type' =&gt; [
                      'id' =&gt; 2
                      'sport_type_name' =&gt; 'ABC Sport'
                  ],
              ],
              1 =&gt; [
                  'id' =&gt; 8,
                  'sport_type' =&gt; [
                      'id' =&gt; 3
                      'sport_type_name' =&gt; 'ABC Sport'
                  ],
              ],
          ],
      ],
      2 =&gt; [
          'name' =&gt; 'Utkarsh Raval',
          'schools' =&gt; [],
          'sports' =&gt; [
              0 =&gt; [
                  'id' =&gt; 8,
                  'sport_type' =&gt; [
                      'id' =&gt; 2
                      'sport_type_name' =&gt; 'DEKTS Sport'
                  ],
              ],
          ],
          'centre' =&gt; [
              0 =&gt; [
                  'id' =&gt; 4,
                  'centre_name' =&gt; 'ABC Centre',
                  'centre_mobile' =&gt; '9898989898',
              ],
              1 =&gt; [
                  'id' =&gt; 5,
                  'centre_name' =&gt; 'XYZ Centre',
                  'centre_mobile' =&gt; '7878787878',
              ],
          ]
      ],
  ];
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YjvXh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YjvXh.png" alt="Demo excel will looks like this image"></a></p>
  
  <p>Thank You...:)</p>