我遇到了一个不寻常的场景,我需要将查询字符串转换为数组。
查询字符串如下所示:
?sort%5B0%5D%5Bfield%5D=type&sort%5B0%5D%5Bdir%5D=desc
解码为:
sort[0][field]=type&sort[0][dir]=desc
如何将它作为可用数组放入我的 PHP 中?IE
echo $sort[0][field] ; // Outputs "type"
我试过邪恶的 eval() 但没有运气。
我需要更好地解释一下,我需要的是 sort%5B0%5D%5Bfield%5D=type&sort%5B0%5D%5Bdir%5D=desc 的文字字符串进入我的脚本并存储为变量,因为它将是在函数中作为参数传递。
我怎么做?