Php 从模型codeigniter获得不同的结果数组
我在使用Codeigniter作为web api方面是新手,我想得到这个结果Php 从模型codeigniter获得不同的结果数组,php,codeigniter,Php,Codeigniter,我在使用Codeigniter作为web api方面是新手,我想得到这个结果 {"result":[{"id":"1","nama":"Orion","nomor":"08576666762"},{"id":"2","nama":"Mars","nomor":"08576666770"},{"id":"7","nama":"Alpha","nomor":"08576666765"}],"success":"1","message":"success"} 但我却得到了这样的结果: {"resu
{"result":[{"id":"1","nama":"Orion","nomor":"08576666762"},{"id":"2","nama":"Mars","nomor":"08576666770"},{"id":"7","nama":"Alpha","nomor":"08576666765"}],"success":"1","message":"success"}
但我却得到了这样的结果:
{"result":[[{"id":"1","nama":"Orion","nomor":"08576666762"},{"id":"2","nama":"Mars","nomor":"08576666770"},{"id":"7","nama":"Alpha","nomor":"08576666765"}]],"success":"1","message":"success"}
我不知道我哪里弄错了
我正在使用codeigniter,下面的代码来自控制器和模型
m_server.php(modals)
删除此行(可选)
换一条线
$result['result'] = $data->result(); //result become the array
array\u push
向现有数组添加元素
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Rest_server extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->model('m_server');
}
public function index()
{
$this->load->helper('url');
$this->load->view('rest_server');
}
function dash_main1(){
$data=$this->m_server->dash_main1();
echo json_encode($data);
}
}
$result['result'] = array();
$result['result'] = $data->result(); //result become the array