</pre><pre code_snippet_id="421967" snippet_file_name="blog_20140708_2_9591675" name="code" class="php"><pre name="code" class="php">
function my_json_decode($str) {
// if (preg_match('/\"\w\":/', $str)) {
// $str = preg_replace('/\"(\w+)\":/is', '$1:', $str); //给key加双引号
// }
$str = preg_replace('/"(\w+)"(\s*:\s*)/is', '$1$2', $str); //去掉key的双引号
return $str;
}
$str = '{"test":[{"testName":"哈哈","Url":"http://www.test.com"}]}';
$str = my_json_decode($str);
echo "$str";
PHP去掉json字符串key的双引号
最新推荐文章于 2023-08-11 09:01:58 发布
本文介绍了一个PHP函数,用于解析JSON字符串并去除键名的双引号,简化了JSON数据处理过程。
1855

被折叠的 条评论
为什么被折叠?



