PHP只返回最后一行JSON

Since few days, I search a soluce for my problem : My PHP return only the last row. This JSON data will be parsed for jsPDF later.

My PHP who get sql data and convert JSON :

    $nexans = json_decode($_GET['nexans'], true);

 $tab_req = array();
   foreach ($nexans as $key => $value) {
         $req_jsonmultipdf = $maPdoFonction->PDF_Multi($key,$value,$_SESSION['ssetablissement_id'],'4','NEXANS');
     $tab_req[] = $req_jsonmultipdf->fetchAll(PDO::FETCH_ASSOC);
   }

        $retour = array(
                 "success" => true,
                 "data" => $tab_req
              );

    echo json_encode($tab_req);

This PHP return only last row and so my table in jsPDF have only one row. How to fix it please ? Thanks for your answer.

This should do it for you

   $tab_req = array();
   foreach ($newarr as $key => $value) {
         $req_jsonmultipdf = $maPdoFonction->PDF_Multi($key,$value,$_SESSION['ssetablissement_id'],'4','NEXANS');
         $tab_req[] = $req_jsonmultipdf->fetchAll(PDO::FETCH_ASSOC);
    }

   $retour = array(
                 "success" => true,
                 "data" => $tab_req
           );

Explanation. You always overwrite your var $req_jsonmultipdf by the last of your loop.