-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetRushtest.php
More file actions
32 lines (23 loc) · 804 Bytes
/
getRushtest.php
File metadata and controls
32 lines (23 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
// Read the contents of the JSON file into a string
$jsonString = file_get_contents('puzzleRush.json');
// Decode the JSON string into an associative array
$data = json_decode($jsonString, true);
// Check if the JSON decoding was successful
if ($data === null) {
die('Error decoding JSON file');
}
// Shuffle the array to randomize the order
shuffle($data);
// Slice the first 88 elements from the array
$randomElements = array_slice($data, 0, 88);
function compareWinrate($a, $b) {
return $b['winrate'] - $a['winrate'];
}
// Sort the array using the custom comparison function
usort($randomElements, 'compareWinrate');
// Encode the selected elements back into a JSON variable
$randomJson = json_encode($randomElements);
// Output the resulting JSON variable
echo $randomJson;
?>