当前位置:网站首页>PHP解析json数据,显示
PHP解析json数据,显示
2022-08-08 19:11:00 【producing】
1、比如我们有像这样一个基层结构的json数据,表面看条件只有三层,后面也是只需要判断这三层并同时循环生成即可。
{"all":[
{"books":
{
"id": 110,
"sec": 1,
"year": 1944,
"pic": "kakaxi.jpg",
"content": "kakajkakhjsb1bdbhbakbdkadad",
"findword": "main keyword",
"author": [
"author-name1",
"author-name2"
],
"key":[
"keyword1",
"keyword2"
]
}}]}
2、上代码(部分)
(1)解析数据获取适合php操作的数据
$url = 'https://haha';
$json_string = file_get_contents($url);
2、开始找数据
$i=0;
// 循环查找内容
function foreachFun($d,$word){
foreach ($d["all"] as $key => $value) {
$allresult = $value;
}
$sortrev='rev&
边栏推荐
猜你喜欢
Lecture 4: Database Definition Language of DDL Type of SQL Statements
[ZJCTF 2019]NiZhuanSiWei
室外光纤资源管理——可视化管理平台
大学生图书馆网页设计模板代码 DIV布局书店网页作业成品 学校书籍网页制作模板 学生简单书籍阅读网站设计成品
Ability in general, but it can be large horizontal jump freely?Where is the better?
WPF DataGrid 展示数据
阿里云数据库PolarDB开源人才培养计划发布!万元好礼等你来拿!
继承的详解
wps表格怎么设置公式自动计算?wps表格设置公式自动计算的方法
数组!!!
随机推荐
黑猫带你学Makefile第7篇:Makefile简单例程一览
shell九九乘法口诀表
USB CY68013设备描述符识别失败
JDBC最详讲解(快速入门)
16. Learn Lua file I/O together
Oracle存储修改以前的历史记录,怎么查找?
[MRCTF2020]你传你码呢
hdu2018 母牛的故事(模拟)
Ability in general, but it can be large horizontal jump freely?Where is the better?
APICloud AVM wraps date and time selection components
工程 (六) ——PointNet点云分类
Fortinet new cloud native protection products launched amazon cloud platform of science and technology
挖财学堂帮开通的证券账户是真的吗?安全吗
对话框管理器第六章:消息循环中的细节
leetcode 240.搜索二维矩阵II 分治思想
RADIUS服务器的演变过程
Build DG will increase the amount of lead to archive log problem
数组!!!
用工具实现 Mock API 的整个流程
企业进行知识共享的好处有哪些?