title: Make in_array like query with MongoDB in PHP
body: <p>I am building a web app and in this app (Codeigniter and MongoDB) I let people search files by tags. For example if they enter the tags house and cat they get all files matching them. The tags are collected in an array ($tags).</p>
  
  <p>This is how I do the find query:</p>
  
  <pre><code>select ($select) -&gt; where_in_all ('tags', $tags) -&gt; get ('uploaded_files');
  </code></pre>
  
  <p>The above query works fine but I really need to let the users search by partial tags.  Like "hou" instead of "house".  I know how to make a like query but only for one tag at a time.  How can I make the in_array search work?</p>
  
  <p>I am using the excellent MongoDB wrapper by vesparny.  This is the code in that wrapper for a normal in_array search:</p>
  
  <pre><code>public function where_in_all($field = "", $in = array()){
     $this-&gt;_where_init($field);
     $this-&gt;wheres[$field]['$all'] = $in;
     return ($this);
  }
  </code></pre>
  
  <p>This is my attempt at modifying it which does not work:</p>
  
  <pre><code>public function where_in_all_like($field = "", $in = array()){
     $this-&gt;_where_init($field);
     $this-&gt;wheres[$field]['$all'] = new MongoRegex('/'.$in.'/i');
     return ($this);
  }
  </code></pre>
  
  <p>What am I doing wrong?
  The wrapper can be found here: </p>
  
  <pre><code>https://github.com/vesparny/cimongo-codeigniter-mongodb-library
  </code></pre>
  
  <p>Thankful for all help!</p>
  
  <p><strong>Update</strong></p>
  
  <p>This seems to work BUT only on my local server... Not on the production server.</p>
  
  <pre><code>public function where_in_all_like($field = "", $in = array()){
  
      $newarray = array ();
  
      foreach ($in as $value) {
       array_push ($newarray, new MongoRegex('/'.$value.'/i'));
      }
  
      $this-&gt;_where_init($field);
      $this-&gt;wheres[$field]['$all'] = $newarray;
      return ($this);
      }
  </code></pre>
  
  <p><strong>Update 2</strong></p>
  
  <p>I updated MongoDB on my server to 2.0.4 and it works fine now.</p>