Skip to content

Instantly share code, notes, and snippets.

@portapipe
Last active June 21, 2019 12:58
Show Gist options
  • Save portapipe/34366a4a217c4e7361a02fef4a90485b to your computer and use it in GitHub Desktop.
Save portapipe/34366a4a217c4e7361a02fef4a90485b to your computer and use it in GitHub Desktop.
PHP code to create a datatables.net compatible JSON output for ajax data type
<?php
$max_rows = 100;
$num_columns = 20;
for($i=0;$i<$max_rows;$i++){
$array = array();
for($n=0;$n<$num_columns;$n++){
$array[] = bin2hex(rand(1000,9999));
}
$rows[] = array_values($array);
}
//var_dump($array);
echo json_encode(array("data"=>($rows)));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment