一个关于PHP数组和JSON的小问题
如何在一个PHP里把{"song":[{"title":"ht1","picture":"ht2","artist":"ht3","url":"ht4"}]}转换成{"title":"ht1","picture":"ht2","artist":"ht3","url":"ht4"}并显示出来,求一段可运行的完整代码,感激不尽!
3回答
-
仙士可
$str = json_decode('{"song":[{"title":"ht1","picture":"ht2","artist":"ht3","url":"ht4"}]}',true);echo json_encode($str['song']);
-
田心枫
你要转换的那个不就在你要的json里面吗 直接取出来不就行了?