将PHP数组转换为Json。使用Code-igniter

时间:2016-04-30 11:01:48

标签: php json codeigniter

我将PHP数组转换为JSON成功但是我的目标没有完全填充。

我的出局是:

{"id":"145","logid":"","name":"asasa"}{"id":"144","logid":"","name":"qwsqwswq"}{"id":"145","logid":"","name":"asasa"}{"id":"144","logid":"","name":"qwsqwswq"}

我的要求:

[{"id":"145","logid":"","name":"asasa"}{"id":"144","logid":"","name":"qwsqwswq"}{"id":"145","logid":"","name":"asasa"}{"id":"144","logid":"","name":"qwsqwswq"}]

这是我的代码: -

if ($AdminRecord) {

                    foreach($AdminRecord->result() as $results)
                    {
                      echo json_encode($results);
                    }
                }

1 个答案:

答案 0 :(得分:4)

您正在输出每一行,而不是尝试:

=