title: PHP - Mongo - $or
body: <p>I am using PHP/Mongo to query a data set like the following:</p>
  
  <pre><code>{
    description:
    {
      0:
        {level: (some int 0-50)},
      1:
        {level: (some int 0-50)},
  
    ...
  
      n:
        {level: (some int 0-50)}
     }
   }
  </code></pre>
  
  <p>How do I write the function, in php, that will build a dynamic query that searches for a level 40 and above, using $or and based on the number of description keys (0 ... n)?</p>
  
  <p>What I currently have for a manual query is not working (I have a feeling it's because in some entries description.1, 2, 3 do not exist):</p>
  
  <pre><code>find("$or":{"description.0.level":[40,41,42,43,44,45,46,47,48,49,50],"descriptio‌​n.1.level":[40,41,42,43,44,45,46,47,48,49,50],"description.2.level":[40,41,42,43,‌​44,45,46,47,48,49,50],"description.3.level":[40,41,42,43,44,45,46,47,48,49,50]}})
  </code></pre>
  
  <p>It gives me an error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'MongoCursorException' with message '$and/$or/$nor must be a nonempty array'</p>
  </blockquote>
  
  <p>So, I need a function that will build the query dynamically, and work :).</p>