Mongodb find() not working as expected, PHP Mongodb find() seems Not to work, I have tried all I could and nothing works so far. using PHP7+ 

I have a Document in the strure like the image below



In SQL I could do something like:SELECT....... where 'common' LIKE '%Burk%'

The simple query is to call the countries collection and produce Burkina Faso as output


  QUERY 1:


$countries_tb= $db-&gt;selectCollection('country_city_data');
 $countries = $countries_tb-&gt;find([],[
    'common' =&gt; new MongoDB\BSON\Regex('Burk')]);
var_dump($countries);


the var_dump prints a list of all the countries in the database instead of getting only Burkina Faso


  QUERY 2:


when I do find(without the empty []), it var_dumps nothing necessary

$countries = $countries_tb-&gt;find(/*without the []*/ [
    'common' =&gt; new MongoDB\BSON\Regex('Burk')]);

var_dump($countries);


I get this:



I have also tried this format.


  QUERY 3:


 $countries = $countries_tb-&gt;find(
                     array('name'=&gt;
 array(  'common'=&gt;new MongoDB\BSON\Regex('Burk'))));

                var_dump($countries);


Still no success.

As suggested by @noobProgrammer from SO below, doing like this:

$countries_tb-&gt;find(['name' =&gt; 
                  ['common'=&gt;new MongoDB\BSON\Regex('Burk')]], 
                  ['typeMap' =&gt; ['root' =&gt; 'array', 'document' =&gt; 'array']]);


Produces this;
I got it working finally!

This is what I did.

$countries = $countries_tb-&gt;find(array('name.common' =&gt;   array('$regex' =&gt;  'Burk') ) );


Notice the . in name.common

Here is my foreach loop'

foreach( $countries as $country =&gt; $name) { 

   foreach ($name as $n){

       if(isset($n-&gt;common)){

            var_dump($n-&gt;common);

        }

   }
}

//It prints out:    country_cities.php:90:string 'Burkina Faso' (length=12)




Somehow, this does NOT work

$countries = $countries_tb-&gt;find(
                         array('name'=&gt;
                                 array('common' =&gt;   
                                         array('$regex' =&gt;   'Burk')) ) );


This is the JSON'

{"_id":"55a0f42f20a4d760b5fc306d","altSpellings":["BF"],"area":272967,"borders":["BEN","CIV","GHA","MLI","NER","TGO"],"callingCode":["226"],"capital":"Ouagadougou","cca2":"BF","cca3":"BFA","ccn3":"854","cioc":"BUR","currency":["XOF"],"demonym":"Burkinabe","landlocked":true,"languages":{"fra":"French"},"latlng":[13,-2],"name":{"common":"Burkina Faso","native":{"fra":{"common":"Burkina Faso","official":"Burkina Faso"}},"official":"Burkina Faso"},"region":"Africa","subregion":"Western Africa","tld":[".bf"],"translations":{"cym":{"common":"Burkina Faso","official":"Burkina Faso"},"deu":{"common":"Burkina Faso","official":"Burkina Faso"},"fin":{"common":"Burkina Faso","official":"Burkina Faso"},"fra":{"common":"Burkina Faso","official":"Burkina Faso"},"hrv":{"common":"Burkina Faso","official":"Burkina Faso"},"ita":{"common":"Burkina Faso","official":"Burkina Faso"},"jpn":{"common":"ブルキナファソ","official":"ブルキナファソ"},"nld":{"common":"Burkina Faso","official":"Burkina Faso"},"por":{"common":"Burkina Faso","official":"Burkina Faso"},"rus":{"common":"Буркина-Фасо","official":"Буркина -Фасо"},"spa":{"common":"Burkina Faso","official":"Burkina Faso"}}}