<legend id='WZgpH'><style id='WZgpH'><dir id='WZgpH'><q id='WZgpH'></q></dir></style></legend>

  • <i id='WZgpH'><tr id='WZgpH'><dt id='WZgpH'><q id='WZgpH'><span id='WZgpH'><b id='WZgpH'><form id='WZgpH'><ins id='WZgpH'></ins><ul id='WZgpH'></ul><sub id='WZgpH'></sub></form><legend id='WZgpH'></legend><bdo id='WZgpH'><pre id='WZgpH'><center id='WZgpH'></center></pre></bdo></b><th id='WZgpH'></th></span></q></dt></tr></i><div id='WZgpH'><tfoot id='WZgpH'></tfoot><dl id='WZgpH'><fieldset id='WZgpH'></fieldset></dl></div>

    <small id='WZgpH'></small><noframes id='WZgpH'>

    • <bdo id='WZgpH'></bdo><ul id='WZgpH'></ul>

    1. <tfoot id='WZgpH'></tfoot>

        在 PHP 中合并两个 json

        时间:2023-10-04
        <tfoot id='FQodf'></tfoot>

        <small id='FQodf'></small><noframes id='FQodf'>

              <tbody id='FQodf'></tbody>
            <i id='FQodf'><tr id='FQodf'><dt id='FQodf'><q id='FQodf'><span id='FQodf'><b id='FQodf'><form id='FQodf'><ins id='FQodf'></ins><ul id='FQodf'></ul><sub id='FQodf'></sub></form><legend id='FQodf'></legend><bdo id='FQodf'><pre id='FQodf'><center id='FQodf'></center></pre></bdo></b><th id='FQodf'></th></span></q></dt></tr></i><div id='FQodf'><tfoot id='FQodf'></tfoot><dl id='FQodf'><fieldset id='FQodf'></fieldset></dl></div>

            <legend id='FQodf'><style id='FQodf'><dir id='FQodf'><q id='FQodf'></q></dir></style></legend>
              <bdo id='FQodf'></bdo><ul id='FQodf'></ul>

                • 本文介绍了在 PHP 中合并两个 json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有两个 json

                  第一个是

                      [{"COLUMN_NAME":"ORDER_NO","COLUMN_TITLE":"Order Number"}
                  ,{"COLUMN_NAME":"CUSTOMER_NO","COLUMN_TITLE":"Customer Number"}]
                  

                  第二个是

                  [{"COLUMN_NAME":"ORDER_NO","DEFAULT_VALUE":"1521"},
                  {"COLUMN_NAME":"CUSTOMER_NO","DEFAULT_VALUEE":"C1435"}]
                  

                  我想合并它们并有一个像

                  I want to merge them and have a json like

                  [{"COLUMN_NAME":"ORDER_NO","COLUMN_TITLE":"Order Number","DEFAULT_VALUE":"1521"}
                  ,{"COLUMN_NAME":"CUSTOMER_NO","COLUMN_TITLE":"Customer Number","DEFAULT_VALUEE":"C1435"}]
                  

                  有没有办法合并它们?如果需要更改 JSON 中的结构,对我来说也可以

                  is there a way to merge them? It is also OK for me if a stucture change in JSON is required

                  谢谢.

                  推荐答案

                  类似 json_encode(array_merge(json_decode($a, true),json_decode($b, true))) 之类的东西应该可以工作.

                  Something like json_encode(array_merge(json_decode($a, true),json_decode($b, true))) should work.

                  array_merge PHP 官方文档

                  array_merge in official PHP documentation

                  json_decode 在 PHP 官方文档中

                  json_decode in official PHP documentation

                  尝试将 true 作为第二个参数添加到 json_decode.这会将对象转换为关联数组.

                  try adding true as second parameter to json_decode. That'll convert objects to associative arrays.

                  EDIT 2:尝试 array-merge-recursive 并在下面查看我的评论.抱歉现在必须退出:(这看起来是一个完整正确的解决方案:https://stackoverflow.com/a/20286594/1466341

                  EDIT 2: try array-merge-recursive and see my comment below. Sorry have to log out now :( This looks like a full correct solution: https://stackoverflow.com/a/20286594/1466341

                  这篇关于在 PHP 中合并两个 json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Mac OS X 上执行 PHP shell 脚本作为 Automator 下一篇:在 PHP 中合并 XML 文件

                  相关文章

                  最新文章

                  <tfoot id='WvDS9'></tfoot>
                  <i id='WvDS9'><tr id='WvDS9'><dt id='WvDS9'><q id='WvDS9'><span id='WvDS9'><b id='WvDS9'><form id='WvDS9'><ins id='WvDS9'></ins><ul id='WvDS9'></ul><sub id='WvDS9'></sub></form><legend id='WvDS9'></legend><bdo id='WvDS9'><pre id='WvDS9'><center id='WvDS9'></center></pre></bdo></b><th id='WvDS9'></th></span></q></dt></tr></i><div id='WvDS9'><tfoot id='WvDS9'></tfoot><dl id='WvDS9'><fieldset id='WvDS9'></fieldset></dl></div>

                  1. <small id='WvDS9'></small><noframes id='WvDS9'>

                      <bdo id='WvDS9'></bdo><ul id='WvDS9'></ul>

                      <legend id='WvDS9'><style id='WvDS9'><dir id='WvDS9'><q id='WvDS9'></q></dir></style></legend>