이 질문을 먼저 게시했지만 모든 사람이 더 쉽게 사용할 수 있도록하기 위해 몇 가지 사항을 명확히해야했습니다.PHP로 JSON 표시
<?php
$array[0]=array("request"=>array("act"=>'user_create',
"user_email"=>"[email protected]",
"user_zone"=>"example.com"));
$array[1]=array('result' => 'success');
$array[2]=array('msg' => 'A message that will be displayed to the end user');
echo json_encode($array);
?>
그 코드 내가 가진 : 여기
{
"request": {
"act": "user_create",
"user_email": "[email protected]",
"user_zone": "example.com"
},
"result": "success",
"msg": "A message that will be displayed to the end user"
...
}
내가 현재 사용하고 코드입니다 ... 내가 JSON으로 출력이 노력하고있어 및 내가 뭘 아무것도 작동하는 것 같다 이 출력은 가깝지 만 꽤 좋지는 않지만 유효한 json 출력이 아닙니다. 여기 변경 만 할 것 확실하지 내가 현재 받고 있어요 무엇 : 사람이 좋은 것 내 고정 된 PHP 코드의 예를 게시하시기 바랍니다 수
[{"request":{"act":"user_create","user_email":"[email protected]","user_zone":"example.com"}},{"result":"success"},{"msg":"A message that will be displayed to the end user"}]
합니다. 나는 지난 몇 시간 동안 서로 다른 솔루션을 테스트하면서 앞뒤로 튀어 오르고 있었고, 내가 원하는 것을 정확히 표시하지 못하는 것 같습니다 :/미리 감사드립니다!
왜 당신이 잘못된 JSON 출력 생각하십니까?를 참조하십시오 []는 배열 구문이고 {}는 객체 구문입니다. – steffen