で連想配列に私は配列を持っている:しますprint_rとき追加キー値PHP
$data["messages"][] = array("chatId" => $chat_id, "type" => "text", "to" => $username, "body" => "success");
配列は、それは次のようになります。
Array ([messages] => Array ([0] => Array ([chatId] => d3a611401de00e8c8b3e225a7cf95484033f57ea18c442249ee9b5bcb63c9a96 [type] => text [to] => pitashi [body] => success)))
しかし、私は、新しいキー値を追加しようとすると、このようなエンド:
$arr_keyboards[] = array(
"type" => "suggested",
"responses" => array(
array("type" => "text", "body" => "Yes"),
array("type" => "text", "body" => "No")
)
);
$data["messages"]["keyboards"] = $arr_keyboards;
私はこれで終わる:
Array ([messages] => Array ([0] => Array ([chatId] => d3a611401de00e8c8b3e225a7cf95484033f57ea18c442249ee9b5bcb63c9a96 [type] => text [to] => pitashi [body] => success) [keyboards] => Array ([0] => Array ([type] => suggested [responses] => Array ([0] => Array ([type] => text [body] => Yes) [1] => Array ([type] => text [body] => No))))))
新しいキー値 "keyboards" => array(...は、前の配列が閉じられた後に追加されます。私はそれが見えるようにしたいです:
Array ([messages] => Array ([0] => Array ([chatId] => d3a611401de00e8c8b3e225a7cf95484033f57ea18c442249ee9b5bcb63c9a96 [type] => text [to] => pitashi [body] => success [keyboards] => Array ([0] => Array ([type] => suggested [responses] => Array ([0] => Array ([type] => text [body] => Yes) [1] => Array ([type] => text [body] => No)))))
私はそれをエンコードしています。ここでは、それがどのように見えるのか、そして私がそれをhttps://www.evernote.com/l/AETNv5OhBI1HtLzqXalq-BCfOIwz4U0jlWwにする必要があるスクリーンショットを示します。そして、最終的に私が見たい方法のスクリーンショットです。https://www.evernote.com/l/AETRjOREKvBHLpXyh3NdZdGAryyxO2rIiwg
私はダムです。助けてくれてありがとう。
:: '$ arr_keyboards [] = ...'あなたが実際にこれをしたい: '$ arr_keyboards = ...' – arkascha