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条)

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题