get_list(); $modelRandNewId = true; while ($modelRandNewId) { $modelRandId = rand(0, count($modelList['models'])-1)+1; $modelRandNewId = $modelRandId == $modelId ? true : false; } header("Content-type: application/json"); echo $jsonCompatible->json_encode(array('model' => array( 'id' => $modelRandId, 'name' => $modelList['models'][$modelRandId-1], 'message' => $modelList['messages'][$modelRandId-1] )));