duanchao1002 2012-02-06 15:10
浏览 34
已采纳

单独的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.

  • 写回答

3条回答 默认 最新

  • duandao1931 2012-02-06 15:17
    关注

    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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向