array(9) {
[productcode] => string(12) 1111
[resourcecode] => string(13) 222
[usercode] => string(9) 333
[tvcode] => string(8) 444
[extrainfo] => string(4) null
[orderresult] => string(1) 1
[subid] => string(2) -1
[payment] => string(1) 1
[_url_] => array(2) {
[0] => string(3) test
[1] => string(14) callback
}
}
eval('$dd='.$result.';');
但是一直报错。汗。
回复讨论(解决方案) 你那个是数组了,还转什么。
我可能没说清楚。上面的字符串。是接口服务器返回过来的。现在要解析这个类似数组的字符串
unserialize(string)
你这个串是怎么得来的。是用var_dump输出的吧,最好贴出全部代码以供分析。
$s = string(9) 333 [tvcode] => string(8) 444 [extrainfo] => string(4) null [orderresult] => string(1) 1 [subid] => string(2) -1 [payment] => string(1) 1 [_url_] => array(2) { [0] => string(3) test [1] => string(14) callback }}txt;$s = preg_replace_callback('/(\[|\]|string|\(\d+\))|({|}|\s+)/', 'foo', $s);$ar = eval('return ' . trim($s, ',') . ';');print_r($ar);function foo($r) { if($r[1]) return ''; if($r[2] == '{') return '('; if($r[2] == '}') return '),'; return ','.php_eol; }
array( [productcode] => 1111 [resourcecode] => 222 [usercode] => 333 [tvcode] => 444 [extrainfo] => null [orderresult] => 1 [subid] => -1 [payment] => 1 [_url_] => array ( [0] => test [1] => callback ))
不要意思。我知道问题了。我犯了个低级错误。不好意思。打扰各位了