我有一個需要使用的陣列,但在 Internet 上找不到任何地方來解釋如何獲取一個欄位并將其放入 PHP 中的 echo 陳述句中。這是陣列。我想抓住“字幕”。
Array
(
[response] => Array
(
[dataInfo] => Array
(
[database] => xxDBxx
[layout] => xxLayxx
[table] => xxTablexx
[totalRecordCount] => 60
[foundCount] => 1
[returnedCount] => 1
)
[data] => Array
(
[0] => Array
(
[fieldData] => Array
(
[title] => Media Links
[subtitle] => Previous NewCo Campaign Media
[permalink] => Media-Links
[reads] => 5233
)
[portalData] => Array
(
)
[recordId] => 62
[modId] => 5333
)
)
)
[messages] => Array
(
[0] => Array
(
[code] => 0
[message] => OK
)
)
)
我在想,如果我的結果作為存盤在 $result 中的陣列回傳,那么我可以從那里拉出該欄位,但我找不到我需要的東西。請幫忙。
uj5u.com熱心網友回復:
當你發布問題時,你必須發布你的陣列,而不是轉儲的結果,所以你的陣列看起來像這樣:
<?php
$result = [
"response" => [
"dataInfo" =>
[
"database" => "xxDBxx",
"layout" => "xxLayxx",
"table" => "xxTablexx",
"totalRecordCount" => "60",
"foundCount" => 1,
"returnedCount" => 1
],
"data" =>
[
"0" =>
[
"fieldData" =>
[
"title" => "Media Links",
"subtitle" => "Previous NewCo Campaign Media",
"permalink" => "Media-Links",
"reads" => "5233"
],
"portalData" =>
[],
"recordId" => 62,
"modId" => 5333
]
]
],
"messages" =>
[
"0" =>
[
"code" => 0,
"message" => "OK"
]
]
];
你可以抓住字幕,像這樣:
echo $result["response"]["data"][0]["fieldData"]["subtitle"];
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/525815.html
標籤:php数组解析括号
