id_to_name($modelId); $modelTexturesList = is_array($modelName) ? array('textures' => $modelName) : $modelTextures->get_list($modelName); $modelTexturesNewId = $modelTexturesId == 0 ? 2 : $modelTexturesId + 1; if (!isset($modelTexturesList['textures'][$modelTexturesNewId-1])) $modelTexturesNewId = 1; header("Content-type: application/json"); echo $jsonCompatible->json_encode(array('textures' => array( 'id' => $modelTexturesNewId, 'name' => $modelTexturesList['textures'][$modelTexturesNewId-1], 'model' => is_array($modelName) ? $modelName[$modelTexturesNewId-1] : $modelName )));