有什么办法可以在PHP中享受decodeValue()
函数吗?我将这些encodedValue值发布到PHP文件中,我需要在PHP中以数组的形式使用它们。ExtJS:DecodeValue in PHP
我该如何结束一个PHP数组或从Ext编码状态的东西?或者,有没有其他方法可以使编码的值能够在PHP中轻松读取?以下是功能代码:
decodeValue : function(cookie){
var re = /^(a|n|d|b|s|o)\:(.*)$/;
var matches = re.exec(unescape(cookie));
if(!matches || !matches[1]) return; // non state cookie
var type = matches[1];
var v = matches[2];
switch(type){
case "n":
return parseFloat(v);
case "d":
return new Date(Date.parse(v));
case "b":
return (v == "1");
case "a":
var all = [];
var values = v.split("^");
for(var i = 0, len = values.length; i < len; i++){
all.push(this.decodeValue(values[i]));
}
return all;
case "o":
var all = {};
var values = v.split("^");
for(var i = 0, len = values.length; i < len; i++){
var kv = values[i].split("=");
all[kv[0]] = this.decodeValue(kv[1]);
}
return all;
default:
return v;
}
}
谢谢。