How to retrieve data from mongodb table in php?
<p>This is my code in php</p>

<pre><code>public function showData(){
    $m = new MongoClient();
    $db = $m-&gt;newdb;
    $collection = $db-&gt;createCollection("signup");
    $data = $collection-&gt;find();
    echo "&lt;pre&gt;";print_r($data);exit;
}
</code></pre>

<p>but it is returning an empty array while i can see the data in the shell. As we can get the data from mongo shell by writing the command <code>db.signup.find().forEach(printjson);</code></p>