dongxun5349 2014-07-17 16:49
浏览 13
已采纳

列表到URL参数

I have a bunch of integers which act as ID's within an ArrayList in my Android application.

This list of id's can be of any amount ranging from 0 - x. These id's are to identify players in a match. What I want is to send data to the web service, telling it that players 1,2 and 3 are on team 1 and players 4,5 and 6 are on team 2.

How best can I construct the URL with the above and how do I properly "expect" and "intercept" these parameters on the server side? I am using PHP.

So far I can think of the following:

 $p1 = $_GET['p1'];
 $p2 = $_GET['p2'];
 $p3 = $_GET['p3'];

But as you can probably guess, that's really bad as I don't know how many people will be in team 1 and how many people in team 2. And further...how to seperate them.

Any ideas?

  • 写回答

1条回答 默认 最新

  • doujupa7567 2014-07-17 16:58
    关注

    You can do a simple list of players in each teams :

    // $_GET['team1'] = '1,2,3';
    $team1 = $_GET['team1'];
    $team1 = explode(',', $team1);
    
    // $_GET['team2'] = '4,5,6';
    $team2 = $_GET['team2'];
    $team2 = explode(',', $team2);
    

    Then you have an array per team, containing the players id.

    Hope it helped !

    EDIT:

    Care of query maxlength here is a link :

    Please note that PHP setups with the suhosin patch installed will have a default limit of 512 characters for get parameters. Although bad practice, most browsers (including IE) supports URLs up to around 2000 characters, while Apache has a default of 8000.

    To add support for long parameters with suhosin, add suhosin.get.max_value_length = in php.ini

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行