$arr = array(
'toemail'=>$v->agent_primary_email,
'agentname'=>$v->agent_firstname,
'agentid'=>$v->agent_id,
'subject'=>'The details of total number of properties saved by your clients',
'totalprop'=>$v->prop_count
);
echo json_encode($arr);exit;
輸出看起來像這樣如何產生陣列
{"toemail":"[email protected]","agentname":"john","agentid":"110012","subject":"The details of total number of properties saved by your clients","totalprop":"131"}
但我應該有什麼樣的變化使,從而使輸出看起來像這樣
{"toemail":"[email protected]",
"agentname":"john",
"agentid":"110012",
"subject":"The details of total number of properties saved by your clients",
"totalprop":"131"}
我的意思是我想在每個對象中有一個新行的輸出,而不是一行中的所有內容。 –
如果它只是用於輸出樣式的目的,只需使用'JSON_PRETTY_PRINT'標誌。它已經在[手冊](http://php.net/manual/en/function.json-encode.php) – Ghost