PHP如何从JSON字符串中提取指定的值?
php 从 json 中获取指定值想要从 json 字符串中获取某个特定值,可以利用 php 的 json 处理功能。具体步骤:解码 json 字符串将 json 字符串转换为 php 数组:$decodeddata = json_decode($jsonstring, true);
echo $decodeddata['item']['content']['url'];
<?php$jsonString = '{ "item": [{ "media_id": "MEDIA_ID", "content": { "news_item": [{ "title": "TITLE", "thumb_media_id": "THUMB_MEDIA_ID", "show_cover_pic": "0", "author": "AUTHOR", "digest": "DIGEST", "content": "CONTENT", "url": "URL", "content_source_url": "CONTENT_SOURCE_URL" }] } }]}';$decodedData = json_decode($jsonString, true);echo $decodedData['item'][0]['content']['url'];