我有这段代码:
$id = 1;
$isTemplate = true;
$address = "address, \n tel. 1234455";
我需要以这种形式保存它:
{"results": [{
"id": 1,
"isTemplate": true,
"text": "<span class=\"d-block option-head\">\n nazwa\n</span>\n<span class=\"d-none\"> - </span>\n<span class=\"d-block option-sub\">\n address,\n tel. 123456\n </span>"
]}
我怎样才能做到?
我尝试:
$resultArray = array('results' => ['id'=> 1, 'isTemplate' => true, 'text'=> '<span class="d-block option-head">\n nazwa\n</span>\n<span class="d-none"> - </span>\n<span class="d-block option-sub">\n address,\n tel. 1234455\n </span>']);
但我的结果是错误的:
Array
(
[results] => Array
(
[id] => 1
[isTemplate] => 1
[text] => <span class="d-block option-head">\n nazwa\n</span>\n<span class="d-none"> - </span>\n<span class="d-block option-sub">\n address,\n tel. 123455\n </span>
)
)
请帮我
慕容森
蝴蝶不菲
慕少森
慕桂英4014372