Php如何从dictionary对象获取数据

Php如何从dictionary对象获取数据,php,arrays,json,dictionary,Php,Arrays,Json,Dictionary,我从API得到的响应如下 [{"destination_url":"https://www.smh.com.au/business/the-economy/australia-s-workplaces-are-transforming-search-where-the-jobs-will-be-in-2024-20180418-p4zaal.html?promote_channel=edmail&mbnr=MjAyNTgyMjU&eid=email:nnn-13omn654-re

我从API得到的响应如下

[{"destination_url":"https://www.smh.com.au/business/the-economy/australia-s-workplaces-are-transforming-search-where-the-jobs-will-be-in-2024-20180418-p4zaal.html?promote_channel=edmail&mbnr=MjAyNTgyMjU&eid=email:nnn-13omn654-ret_newsl-membereng:nnn-04%2F11%2F2013-news_am-dom-news-nnn-age-u&campaign_code=13INO010&et_bid=29124074&list_name=40_smh_newsalert&instance=2018-04-18--20-11--UTC",
  "doc_id":"17014",
  "main_url":"http://click.email.fairfaxmedia.com.au/?qs=b3370d8980e989c9e39909e0291c60d501f8a164477f9e049f07626b2a9c7e79da7d38ad705d7713e024559ecf2f217f79f8c08f728ab7fe",
  "redirect_urls":"http://click.email.fairfaxmedia.com.au/?qs=b3370d8980e989c9e39909e0291c60d501f8a164477f9e049f07626b2a9c7e79da7d38ad705d7713e024559ecf2f217f79f8c08f728ab7fe||http://www.smh.com.au/business/the-economy/australia-s-workplaces-are-transforming-search-where-the-jobs-will-be-in-2024-20180418-p4zaal.html?promote_channel=edmail&mbnr=MjAyNTgyMjU&eid=email:nnn-13omn654-ret_newsl-membereng:nnn-04%2F11%2F2013-news_am-dom-news-nnn-age-u&campaign_code=13INO010&et_bid=29124074&list_name=40_smh_newsalert&instance=2018-04-18--20-11--UTC"
}]"
现在我必须从这里访问
doc\u id
。以下是我尝试过的:

$landerProperties = $request->data;
$landerProperties = json_decode(json_encode($landerProperties,true),true);
$id = (int)$landerProperties[0]['doc_id'];
foreach ($landerProperties as $key => &$value) {
   unset($value['doc_id']);
}

但它给了我一个例外:
非法字符串偏移量“doc\u id”
。请告诉我如何从这里访问数据。

如果要访问第一个,请使用以下命令:(注意json字符串周围的单引号)

代码:()

输出:

17014

包括您最好的编码尝试——这是对您的期望的一部分。目前,您似乎没有进行任何研究,也没有进行任何尝试。StackOverflow不是免费的编码服务。这可能会被一个非常通用的“如何解析json”副本所困扰。我正在尝试——我们没有看到您在这个问题上的任何尝试。这还不够information@mickmackusa请检查,我已经在这里添加了代码。如果有人不粘贴代码示例,并不意味着他没有尝试任何东西。许多人在这里辱骂志愿者,我们不能认为你是一个好的或坏的海报——最好证明你的问题是“值得的”。谢谢,这里有无效的json问题
17014