Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当使用逗号分隔的查询字符串API时,如果查询字符串本身包含逗号该怎么办?_Php_Api - Fatal编程技术网

Php 当使用逗号分隔的查询字符串API时,如果查询字符串本身包含逗号该怎么办?

Php 当使用逗号分隔的查询字符串API时,如果查询字符串本身包含逗号该怎么办?,php,api,Php,Api,我正在设计一个API,但这里有一个问题: ?merchantCategoryName=[Adult,Fantasy,Mac] &mappedCategoryID=[701,80,22] &merchantID=36330&outputType=xml 这是理想的情况,但是如果merchantCategoryName包含如下逗号会怎么样:(Ad,ult是merchantCategoryName) 然后将是无序的,如果我使用base64它似乎不起作用,如果我使用htmlen

我正在设计一个API,但这里有一个问题:

?merchantCategoryName=[Adult,Fantasy,Mac]
&mappedCategoryID=[701,80,22]
&merchantID=36330&outputType=xml
这是理想的情况,但是如果
merchantCategoryName
包含如下逗号会怎么样:(
Ad,ult
merchantCategoryName


然后将是无序的,如果我使用
base64
它似乎不起作用,如果我使用
htmlentities
它似乎是
的实体是
。那么我该如何解决这个问题呢

您可以使用以下格式:

?merchantCategoryName[]=Adult&
merchantCategoryName[]=Fantasy&
merchantCategoryName[]=Mac&
merchantID=36330&
outputType=xml

有关详细信息,请参见问题

使用其他分隔符perhaps@RamRaider我认为每个分隔符都有机会出现这种情况,特别是我的项目是多语言支持。但我的接收点是JAVA,JAVA会解析这个URL,它在JAVA中工作吗?还有,有可能
merchantCategoryName
可以
Adu<
我不了解JAVA,您设置标签
php
:)以转义需要使用的php中的特殊字符,是的,它是php解析url,JAVA是API提供程序如果我使用
urlencode
,所有逗号都将被编码,包括分隔符
?merchantCategoryName[]=Adult&
merchantCategoryName[]=Fantasy&
merchantCategoryName[]=Mac&
merchantID=36330&
outputType=xml