I want to retrieve all the values of the field color. How do php handle this values?
{
_id : 1,
color : ["red","blue","yellow"]
},
{
_id : 2,
color : ["green","black","grey"]
}
PHP code :
<?php
$connect = new MongoClient();
$collection = $database->database_name->collection;
$cursor = $collection->find( array(), array( 'color' ) );
foreach( $cursor as $val )
echo json_encode( $val );
?>
As a result it does not return any values. How do I get the array values?