$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