<?php 
    error_reporting(E_ALL);
    ini_set('display_errors', 1);

    $filename = '/tmp/dashboard/sendPostfix';        
    $arr = [];
    $handle = fopen($filename, "r");
    if ($handle) {
        while (($line = fgets($handle)) !== false) {
            $json = json_decode($line, true);
           // print_r($json);
            if(empty($json) == TRUE){
                continue;
            }else{
                array_push($arr, $json);
            }
        }
        fclose($handle);
    } else {    
       echo "não foi possível abrir o ficheiro.";
    }

    $id = array();
    foreach ($arr as $key => $row){
        $id[$key] = $row['idUser'];
    }
    array_multisort($id, SORT_ASC, $arr);

   // print_r($arr);
    
    $jTableResult = array();
    $jTableResult['Result'] = "OK";
    $jTableResult['Records'] = $arr;
    print json_encode($jTableResult);
    
    
?>