当前位置:编程学习 > php >>

用php中的正则表达式把{\"textField7\":\"ttt\",\"textField8\":\"tttt\"} string型转换为array型

补充:变成 Array ( [textField7] => tt [textField8] => ttt )
答案:$str = "{\"textField7\":\"ttt\",\"textField8\":\"tttt\"}";
print_r( json_decode($str, true) );
其他:preg_match_all('#\\"(.+)\\":#i', '{\"textField7\":\"ttt\",\"textField8\":\"tttt\"}', $text); 
preg_match_all('#:\\"(.+)\\"#i', '{\"textField7\":\"ttt\",\"textField8\":\"tttt\"}', $text2); 

for ($i=1; $i<count($text); $i++){
$myarray .= array($text[$i],$text[$i]);
} 

上一个:php中用于改变字符集编码的函数是什么
下一个:我在网上下PPT模板,但是下下来的是php的格式,怎么办?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,