Exemplo n.º 1
0
 /**
  * @return string
  * @throws Exception
  */
 public static function toJson()
 {
     $array = Export::data();
     if (count($array) == 0) {
         throw new Exception("Array cannot be empty");
     }
     // disable caching
     $filename = "data_" . date('d-m-Y') . ".json";
     $now = gmdate("D, d M Y H:i:s");
     Export::headers($filename, $now);
     ob_start();
     $response = array();
     $response["users"] = $array;
     $fp = fopen("php://output", 'w');
     fwrite($fp, json_encode($response));
     fclose($fp);
     return ob_get_clean();
 }