</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的双引号
最新推荐文章于 2024-08-13 14:54:57 发布