php - 从 json 打印 PHP 文本
问题描述
Wikipedia API 中有这样一个 json:https ://ru.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Apple
如何从短文本开始的php中的php字段输出文本?
我试过这样,但没有任何效果:
$url = file_get_contents('https://ru.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Apple');
$yummy = json_decode($url, true);
echo $yummy['extract'];
解决方案
这样做我调试你在查询>页面>数字中提取的
$url = file_get_contents('https://ru.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=Apple');
$yummy = json_decode($url, true);
$datas=$yummy['query']['pages'];
foreach($datas as $data){
$extract = $data['extract'];
}
echo $extract;
推荐阅读
- python-3.x - 为什么生产者在我的示例中几乎完全重新获取条件线程?
- r - 如何让 document() 接受 µ
- javascript - Nodejs:正则表达式不返回任何内容
- tableau-api - 如何设置非连续日期过滤器?
- c++ - C ++:如何使用其参数之一对从类派生的对象向量进行排序
- python - python input() 在调用 input() 之前采用旧的标准输入
- reporting-services - 如何删除以“和”SSRS 2016 表达式结尾的行上的最后 3 个字符?
- postgresql - 如何避免 Postgres 中的静态查询?
- java - Recursively finding words in a hashmap using tries
- r - 通过匹配所有可能的行和列的键来添加任何缺失的行和列