title: How do you get the string value of a MongoID using PHP?
body: <p>After doing an insert I want to pass the object to the client using json_encode(). The problem is, the _id value is not included.</p>
  
  <pre><code>$widget = array('text' =&gt; 'Some text');
  
  $this-&gt;mongo-&gt;db-&gt;insert($widget);
  
  
  If I echo $widget['_id'] the string value gets displays on the screen, but I want to do something like this:
  
  $widget['widgetId'] = $widget['_id']-&gt;id;
  
  
  So I can do json_encode() and include the widget id:
  
  echo json_encode($widget);
  </code></pre>