在PHP中使用相同的元素创建JSON

I might be missing something obvious but is it possible to create a JSON like this with json_encode?

{
    'foo': 'bar',
    'foo': 'baz'
}

UPDATE

I had to note from the start that I'm aware that what I'm asking smells bad. However this is what SOLR is requiring. See http://wiki.apache.org/solr/UpdateJSON

No, json_encode won't give you a result with duplicate keys, since the object/array you're encoding cannot have had multiple values for one property/key, but you could store the same data a couple different ways. The most natural is probably:

{
    "foo": ["bar", "baz"]
}

You could also do something like:

[
   { 
     "key": "foo",
     "value": "bar"
   }, 
   { 
     "key": "foo",
     "value": "baz"
   }
]

If you must obtain that syntax for SOLR, you can obtain it by combining multiple calls to json_encode, although it isn't pretty:

$foo1 = [ 'foo' => 'bar' ];
$foo2 = [ 'foo' => 'baz' ];

echo rtrim( json_encode( $foo1 ), '}' ) . ',' . ltrim( json_encode( $foo2 ), '{' );
// {"foo":"bar","foo":"baz"}