How send to client a lot of data

I have a problem. I need to send to android-client a json text and a lot of images but dont know how it all send via responce. Can you give some tips

app->get(’/test’, function (Request $request, Response $response) {
$array=array();
$image1=file_get_contents(“http://newdevstory.esy.es/media/images/test.png”);
$image2=file_get_contents(“http://newdevstory.esy.es/media/images/test2.png”);
$partitions=‘design’;
$array[]=R::getRow(‘SELECT title FROM titles WHERE part=?’,array($partitions));
$array[]=R::getRow(‘SELECT caption FROM captions WHERE part=?’,array($partitions));
$date=json_encode($array,JSON_UNESCAPED_UNICODE);

$response->write();
return $response->withHeader('Content-Type',FILEINFO_MIME);

});

Hi,

Since it seems you want to return JSON, I’d suggest to use the following at the end of your function:

return $response->withJson($array, 200);

The documentation specifies that in this case (sending a JSON response using withJson, you don’t have to bother setting the Content-Type header, Slim does it for you).

Also note that you don’t use $image1 and $image2.

i need return json array and two(maybe more image) to client =\

I’m not sure what you mean when writing:

i need return […] and two(maybe more image) to client

Can’t you return an URL for each of these images and let your Android app deal with them ?
That way you would send JSON data, and in your JSON response you would have your images URLs.

Something like:

$data = array();
$data["images"] = array();
$data["images"][0] = "https://example.org/pics/image1.jpg";
$data["images"][1] = "https://example.org/pics/image2.jpg";
$data["whatever"] = "you want";

return $response->withJson($data);

thanks you for help me)