Return to Snippet

Revision: 51728
at October 2, 2011 14:42 by lemcoe9

Initial Code
$m = new Mongo();
$db = $m->test;
$collection = $db->david;
$cursor = $collection->find();
$array = iterator_to_array($cursor);
$keys = array();
foreach ($array as $k=>$v) {
        foreach ($v as $a=>$b) {
                $keys[] = $a;
$keys = array_values(array_unique($keys));

Initial URL

Initial Description
Takes the collection 'david' and gives a unique array of the keys used.

Initial Title
List of Keys Used in MongoDB Collection

Initial Tags
php, array

Initial Language