单独的HTTP连接结果(PHP回声)
In my Android application I make a HTTP POST connection:
serverresponse = CustomHttpClient.executeHttpPost(url, postParameters);
All working fine. The url
is pointing to a php page on my server. It echos an array of image urls in JSON format like this:
[".\/pictures\/q\/thumbnails\/28052011172.jpg",".\/pictures\/q\/thumbnails\/picca1.jpg",".\/pictures\/q\/thumbnails\/lockscreen_006.jpg"]
What I want to do is also echo the size of directory. That works fine too, but that puts it right after the JSON array, like so:
echo (json_encode($files));
echo (filesize_r($path));
[".\/pictures\/q\/thumbnails\/28052011172.jpg",".\/pictures\/q\/thumbnails\/picca1.jpg",".\/pictures\/q\/thumbnails\/lockscreen_006.jpg"]4223566
4223566 is the number of bytes. In my application I want to split these two values into different strings so I can use them.
In short, I want to separate these two php echos. I don't want to make two separate HTTP connections for both of them.
Sorry if my question isn't clear enough, I sometimes have a hard time explaining stuff in English.
在我的Android应用程序中,我建立了一个HTTP POST连接: p>
serverresponse = CustomHttpClient.executeHttpPost(url,postParameters);
code> pre>
一切正常。 url code>指向我服务器上的php页面。 它回显了一个JSON格式的图像网址数组,如下所示: p>
[“。\ / pictures \ / q \ / thumbnails \ /28052011172.jpg”,“。\ / pictures \ / q \ / thumbnails \ /picca1.jpg“,”。\ / pictures \ / q \ / thumbnails \ /lockscreen_006.jpg“] code> p>
我想要什么 要做的还是回显目录的大小。 这也很好,但是它就在JSON数组之后,就像这样: p>
echo(json_encode($ files));
echo(filesize_r($ path)) ; “\ /图片\ / q \ /缩略图\ /28052011172.jpg”。
代码> PRE>
[,“\ /图片\ / q \ / 缩略图\ /picca1.jpg“,”。\ / pictures \ / q \ / thumbnails \ /lockscreen_006.jpg“] 4223566 code> p>
4223566是字节数。 在我的应用程序中,我想将这两个值拆分为不同的字符串,以便我可以使用它们。 p>
简而言之,我想分开这两个php回声。 我不想为它们两个单独的HTTP连接。 p>
对不起,如果我的问题不够清楚,我有时很难用英语解释一些东西。 p>
div>
Could you not just make one json object which contains the two values your require?
e.g.
$response = array(
'pictures'=>$files,
'filesize'=> filesize_r($path)
);
echo json_encode($response);
Use params in you php so you can select wich action to do
not sure if I understand your question fully, but:
$json['files'] = $files;
$json['size'] = filesize_r($path);
echo json_encode($json);