It turns out that the PHP code that answers this question was not that difficult, actually:
$query = array('_id' => 'id1', 'list.type' => 'type1');
$result = $collection->find($query);
/* Use this to access each element of the results */
foreach($result as $doc) {
/* Code goes here */
}
If one wants to use each value in "type"
instead (and print them all for example), the code would be:
$output = [];
$query = array('_id' => 'id1');
$field = array('list.type' => true);
$result = $collection->find($query, $field);
foreach($result as $doc) {
foreach($doc['list'] as $elem) {
$output[] = $elem['type'];
}
}
I found out all of this by using the var_dump()
function on each document and analyzing the output. Hope this helps beginners like me. Thanks to Sammaye for the tips! :)