我具有以下删除对象的功能。我想知道如何使用状态将idArray传递给此函数?
function deleteDocs($idArray, $operation = 'delete'){
$batch = array();
foreach($idArray as $id){
$batch[] = array(
'type' => $operation,
'id' => $id);
}
$batch = array_filter($batch);
$jsonObj = json_encode($batch, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
$result = $this->client->uploadDocuments(array(
'documents' => $jsonObj,
'contentType' =>'application/json'
));
return $result['status'] == 'success' ? mb_strlen($jsonObj) : 0;
}