0) { foreach ($array as $k => $v) { if (is_array($v)) { foreach ($v as $k2 => $v2) { if ($k2 == $on) { $sortable_array[$k] = $v2; } } } else { $sortable_array[$k] = $v; } } switch ($order) { case SORT_ASC: asort($sortable_array); break; case SORT_DESC: arsort($sortable_array); break; } foreach ($sortable_array as $k => $v) { $new_array[$k] = $array[$k]; } } return $new_array; } $app_name = "wpJson"; $errorLevel = E_ERROR; $flog=fopen( $app_name .".log" , 'a' ); $GLOBALS["screenLog"]=0; require_once 'myLib.php'; error_reporting(0); ini_set('display_errors', '0'); //this script is meant to be ran outside of WP $curdate_utc = date("Y-m-d H:i:s"); $file = fopen("players.txt", "r"); $members = array(); while (!feof($file)) { $members[] = fgets($file); } fclose($file); $leaderboards=$members; class cPlayer { public $name; public $gross; function __construct($name) { $this->name = $name; $this->gross = 72+(rand(-5,28)); } } $leaderboard=array( ); for ($i=0;$iname; $leaderboard[$i]["toPar"]=$player->gross-72; $leaderboard[$i]["thru"]=18; $leaderboard[$i]["rd"]=1; $leaderboard[$i]["fav"]=5; } $leaderboard=array_sort($leaderboard, 'toPar'); //myPrint_r0($leaderboard); header('Content-Type: application/json'); // Encode the response array to JSON format $jsonResponse = json_encode($leaderboard); // Send the JSON response //fwrite($flog,$leaderboard); echo $jsonResponse;