0

i've two php array that i want to export on an excel. i tried this:

 $tab=array_merge($tab1,$tab2);
 $activeSheet = $spreadsheet->getActiveSheet()
     ->fromArray(   $tab,   
                    NULL,       
                    'A1'  );

and i got this result

 BF     A   3,3032E+13
 BF-SA  A   3,0641E+13  
 220000000  165000  
 240000000  167334  

It put tab2 data below tab1 data but i want it to put tab1 first line and tab2 fist line on the same line knowing that tab1 and tab2 have same number of line.

i've also tried $tab=$tab1+$tab2; but it doesn't work.

AnatPort
  • 748
  • 8
  • 20
F.Sorgho
  • 3
  • 2

1 Answers1

0

If Arrays have the same number of line as you said so you can use:

$tab1=[['BF', 'A' ,'3,3032E+13'],[ 'BF-SA' ,'A', '3,0641E+13']];  
$tab2=[[220000000,  165000]  , [240000000 , 167334 ]] ;

$tab=array_map(function($a,$b){return array_merge($a,$b);},$tab1,$tab2);
$activeSheet = $spreadsheet->getActiveSheet()
 ->fromArray(   $tab,   
                NULL,       
                'A1'  );
Elementary
  • 1,443
  • 1
  • 7
  • 17