Docs Menu
Docs Home
/ / /
PHP Library Manual
/ / /


On this page

  • Definition
  • Return Values
  • Examples
  • See Also

Return the index name. This correlates with the return value of MongoDB\Collection::createIndex(). An index name may be derived from the $key parameter or explicitly specified via the name option.

function getName(): string

The index name.

$info = new IndexInfo([
'name' => 'x_1',
echo $info->getName();

The output would then resemble:

  • MongoDB\Collection::createIndex()

  • listIndexes command reference in the MongoDB manual

← MongoDB\Model\IndexInfo::getKey()