A small change to the earlier example will result in a more user-friendly output that will be easier on the eye:
<?php
$dbname = 'members'; // Previously created database
$conn = new MongoClient("localhost");
$list = $conn->selectDB($dbname)->getCollectionNames();
foreach ($list as $coltion) {
$colName = $coltion;
echo '<p>Collection name is: <em>';
echo $colName;
echo '.</em></p>';
}
?>
This will produce an output similar to the following;
Collection name is: addresses.