Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中从多维数组中获取数据_Php_Multidimensional Array - Fatal编程技术网

如何在php中从多维数组中获取数据

如何在php中从多维数组中获取数据,php,multidimensional-array,Php,Multidimensional Array,你好,我想从多维数组中获取单个值。到目前为止,我已经做到了这一点 print_r($result); 并且有这样的输出 Array ( [All Nodes Are Shuddha] => stdClass Object ( [answer] => All Nodes Are Shuddha ) ) 请告诉我如何只使用“所有节点都是Shudha”也许: echo $result['All Nodes Are Shuddha']->answer;

你好,我想从多维数组中获取单个值。到目前为止,我已经做到了这一点

print_r($result);
并且有这样的输出

Array (
   [All Nodes Are Shuddha] => stdClass Object (
      [answer] => All Nodes Are Shuddha
   )
) 
请告诉我如何只使用“所有节点都是Shudha”

也许:

echo $result['All Nodes Are Shuddha']->answer;

请通过将对象转换为数组按如下方式使用它

$arr = (array) $result['Äll Nodes are shudhha'];
print_R($arr['answer']);

你不是有两个相同值的等级吗,你想要哪一个,内部的那个?还是外部的?是的,我也尝试过使用foreach,但它说stdclass object error。,我想要外部数组值是的,我想说同样的,直到我注意到它提到了两个未定义的索引:所有节点都是Shuddha@AnkushSeth您的打印(结果);表示存在“所有节点都是Shuddha”。也许第一个字母“Ä”是不同的。未定义索引:所有节点都是Shuddha@AnkushSeth请将“所有节点都是Shuddha”替换为输出中打印的。我想这把钥匙可能有一些特殊的特征。请检查我的更新。
foreach($result as $key => $values) {
   echo $key; // this should get the key 'All Nodes Are Shuddha'
}