php - 回显/打印特定 JSON 字段 PHP
问题描述
我有一个具有以下结构的 JSON:
{
"content": [
{
"id": 119273908,
"numeroPeca": "0008919712005802000110000125",
},
{
"id": 25926466,
"numeroPeca": "0500013942009802003310000126",
},
{
"id": 124435361,
"numeroPeca": "0800040772017802001510000124",
},
{
"id": 79760181,
"numeroPeca": "0066239062010802000110000118",
}
],
"last": false,
"totalElements": 6402,
"totalPages": 4,
"size": 2000,
"number": 0,
"sort": null,
"first": true,
"numberOfElements": 2000
}
我想捕获“totalPages”字段
我的部分代码(PHP):
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$array = json_decode($response, true);
echo $array['content'];
}
然而,答案是:
注意:第 39 行 C:\xampp\htdocs\acre.php 中的数组到字符串转换
解决方案
推荐阅读
- delphi - 如何在 Firemonkey 中创建带圆角的 ListView/Listbox?
- ios - iOS:如何清除 PDFView?
- three.js - 如何在修改后的 MeshPhysicalMaterial 着色器中更新阴影
- python - 从 csv 中删除多余的时间戳
- python - form.is_valid() 未正确验证
- pandas - 使用大量数据创建 H5 数据库错误
- android - 如何从 Kotlin 中的片段访问主机活动中的晶圆厂?
- postman - Postman 测试 - 使用变量解析 JSON 请求时出错
- python - 如何在 Windows 上激活 virtualenv?
- fonts - LaTeX 繁体中文字体,PDF中的数字不可搜索