<?php
function deleteIndex($db, $collection, $indexName) {
if (class_exists("MongoClient")) {
$m = new MongoClient();
} else {
$m = new Mongo();
}
$indexes = $m->{$db}->{$collection}->getIndexInfo();
foreach ($indexes as $index) {
if ($index['name'] === $indexName) {
return $m->{$db}->command(array("deleteIndexes" => $this->m->{$db}->{$collection}->getName(), "index" =>$index['key']));
break;
}
}
return false;
}
$response=deleteIndex('student','class','roll');
echo "<pre>;
print_r($response);
echo "</pre>";
?>
Array
(
[nIndexesWas] => 2
[ok] => 1
)