我试图回显json_encode
一个包含对象数组的关联数组。输出始终为空白。我的代码如下。有人可以建议吗?
$repeatSerialNumArray = array();
// Total number of records inserted
$totalRecordsInserted = 0;
以下是while循环:
$dsRecordObject = new dsRecord($SerialNumber, $MAC_Address);
array_push($repeatSerialNumArray, $dsRecordObject);
然后我回显结果对象数组:
$output['repeatObjects'] = $repeatSerialNumArray;
$output['records_inserted'] = $totalRecordsInserted;
$output['message'] = 'fileUploadedRead';
echo json_encode($output);
我知道如果从上面消除$output['repeatObjects'] = $repeatSerialNumArray;
,我会得到一个JSON输出。
class dsRecord{
public $SerialNumber;
public $MAC_Address;
public function __construct($SerialNumber, $MAC_Address){
$this -> SerialNumber = $SerialNumber;
$this -> MAC_Address = $MAC_Address;
}
}