Sort 3 arrays according to the first array

0

I have 3 separate arrays in $ students, $ sites, $ considerations. I'm trying to sort out my data through the $ students array. When I order the $ students array, the other two arrays that have row-to-row bindings with the $ students array are incorrect.

How do I sort the array $ students and reflect on the other two arrays $ sites, $ considerations?

My arrays:

Array $students
(
    [0] => Stew2 Dent
    [1] => Stew1 Dent
    [2] => Stew5 Dent
    [3] => Stew4 Dent
)
******Array $sites
(
    [1] =>      GRH
    [2] =>      STB     GRH
    [3] =>      STB     GRH
    [4] =>      GRH     CON
)
******Array $consideracoes
(
    [0] =>           LT          WF          BA          PE
    [1] =>           BA
    [2] =>           LT          PE
    [3] =>           LT          PE
)

This is my code. I tried to use asort, but it is not working.

function printPDF($students, $sites, $considerations)
{ 
    $marginLeft=15;
    $marginRight=15;
    $marginTop=25;
    $pdf = new PDF(); 
    $pdf->AliasNbPages();
    $pdf->AddPage('L'); 
    $pdf->SetMargins($marginLeft, $marginTop,  $marginRight, true);
    $pdf->SetAutoPageBreak(true, $marginTop);
    $fileOutput= "Report.pdf";
    $pdf->SetFont('helvetica','',  10);
    $lineX=12; //space btw answers
    $lineY=5;
    $id=0;

   asort($students, $sites);

for ($i=0; $i <count($sites); $i++) 
    {
        $pdf->SetX($marginLeft+10 );
        $pdf->Cell($lineX,$lineY,++$id,0,0,'L');
        $pdf->Cell($lineX+22,$lineY,$students[$i],0,0,'L');

        $pdf->Cell($lineX+80,$lineY,$sites[$i+1],0,0,'L');

        $pdf->Cell($lineX+100,$lineY,$considerations[$i],0,1,'L');
    }

$pdf->Output('reports/'.$fileOutput, 'F');

}
    
asked by anonymous 12.08.2018 / 20:02

0 answers