<slide>
<title>Querying: matching array elements</title>

<div effect="fade-out">
<example result="2"><![CDATA[<?php
$m = new MongoClient;
$c = $m->demo->continent; $c->drop();
$c->insert( [
    'name' => 'South America',
    'cities' => [
        [ "name" => "Buenos Aires", "population" => 13076300, "dem" => 131 ],
        [ "name" => "São Paulo", "population" => 10021295, "dem" => 769 ],
    ]
] );
$c->insert( [
    'name' => 'Asia',
    'cities' => [
        [ "name" => "Karachi", "population" => 11624219, "dem" => 38 ],
        [ "name" => "Moscow", "population" => 10381222, "dem" => 144 ],
        [ "name" => "İstanbul", "population" => 11174257, "dem" => 39 ],
    ]
] );
?>]]></example>

<blurb>Continent with a city of more than 11 million people and above 100
meter.</blurb>
</div>

<div effect="fade-in">
<example result="1"><![CDATA[<?php
$m = new MongoClient;
$c = $m->demo->continent;
$r = $c->find( [
    'cities.population' => [ '$gte' => 11000000 ],
    'cities.dem' => [ '$gte' => 100 ],
] );

foreach( $r as $c ) {
    echo $c['name'], "\n";
    foreach( $c['cities'] as $city ) {
        echo '- ', $city['name'], ': ', $city['population'], ' - ', $city['dem'], "\n";
    }
}
?>]]></example>
</div>
</slide>
