I try to get a large data from mongoDB, but it returned broken on the midle, like [item, item, ite .
When i request smaller data everyfing is ok.
Code in php file:
if ($location) {
//define cursor
$rest = $collection->find(['borough' => $location]);
//make array of restaurants names
foreach ($rest as $restaurant) {
if ($restaurant['name'] != '') {
$array[] = $restaurant['name'];
}
}
//forming response
if ($array) {
echo json_encode(
$array,
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP
);
}
else {
http_response_code(204);
}
exit();
}
Getting " SyntaxError: Unexpected token in JSON at position 65528 " when i parse it in JS, and allways same position no matter what is a data. This is probably php problem, because if JSON make from $array=range(1,1000000) i give a same result. Any idea?
upd: sorry, coppied wrong section of code. Edited.