連想配列で中身が空のものを作成したいのですが、書き方がわかりません。solrのコミットのコマンドとなるように、{"commit":{}} となるようにしたいです。
調べてみたところ、下記のサイトのように書けば出来ると思ったのですが、
参考URL
http://d.hatena.ne.jp/ajiyoshi/20120912/1347434440
NULL
array(1) {
["commit"]=>
object(stdClass)#49 (0) {
}
}
どのように書いたら、{"commit":{}} となるのでしょうか?
よろしくお願い致します。
var_dump($body);
lang
1public function commiy(){ 2 //echo 'hello';exit; 3 //$body = array('commit'=>['doc' => '']); 4 //$body = array('commit' => array()); 5 //$body = array('commit' => array()); 6 //$body = array('commit' => array()); 7 //$body = array('commit' => ''); 8 $body = array( 9 'commit' => (object)array(), 10 11 ); 12 13 var_dump($body); 14 //if (count($body) > 0) { 15 $this->set_update_context($body); 16 $json = file_get_contents('http://'. $this->_server. ':'. $this->_port. $this->_update_api, 17 false, $this->_context); 18 $response = json_decode($json); 19 // } 20 //var_dump($response); 21 return $response; 22 23 24 }

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/03 09:33