/ Published in: PHP
Takes the collection 'david' and gives a unique array of the keys used.
Expand |
Embed | Plain Text
$m = new Mongo(); $db = $m->test; $collection = $db->david; $cursor = $collection->find(); $array = iterator_to_array($cursor); foreach ($array as $k=>$v) { foreach ($v as $a=>$b) { $keys[] = $a; } }
Comments
Subscribe to comments
You need to login to post a comment.

Hi lemcoe9, I wanted to you let you know that as this seems like a common problem, I have created an open source to analyze the keys, in a collection, called Variety.
Check it out here: https://github.com/jamescropcho/variety and let me know if you have an issues or any questions.
Good luck!