PHP json_encode不编码...为什么?

时间:2015-11-12 15:26:01

标签: php arrays json

我在$ arrayResult中有以下数组:

array (size=1)
  'Records' => 
    array (size=1498)
      0 => 
        array (size=4)
          'code' => string '9999999' (length=12)
          'nome' => string 'XXXXXXXXX' (length=39)
          'contrato' => string '67971' (length=5)
          'status' => string 'A' (length=1)
      1 => 
        array (size=4)
          'code' => string '777777777' (length=12)
          'nome' => string 'WWwwwwwww' (length=40)
          'contrato' => string '67725' (length=5)
          'status' => string 'C' (length=1)

    .... (other results with the same pattern)

    $resultArray = $view->getAllAccounts();
    $final['Records'] = $resultArray;
    echo json_encode($final, true);

当我得到数组并使用json_encode时没有任何反应。

1 个答案:

答案 0 :(得分:4)

无论您到目前为止编写的数据结构和代码如何,如果您使用json_decodejson_encode遇到意外行为,请使用json_last_error和/或json_last_error_msg查看发生了什么。