0
이렇게하는 것이 더 좋은 방법일까요? 사운드 컬렉션에서 모든 문서를 가져와 객체이 포함 된 배열로 출력하고 싶습니다 (backbone.js 용으로 사용). 개체가 들어있는 개체가 없습니다!from mongodb from 객체 배열
$sounds = iterator_to_array($db->sounds->find());
$a = "[";
foreach ($sounds as $id => $sound) {
$a .= json_encode($sound) . ",";
}
//remove the last comma...
$a = substr($a, 0, -1);
$a .="]";
echo $a;
'echo json_encode (array_values ($ sounds));'는 어떻습니까? – Leri
예! 이 위대한 작품! 그게 뭔지 설명해 주시겠습니까? – tobbe
설명과 함께 답변으로 게시 해 드리겠습니다. – Leri