从关联数组错误中检索值
Retrieve value from associative array-error
你好
我偶然发现了一个有点简单的问题,但我无法理解也不知道哪里出了问题:
function zabbixGraphGetId($HostName, $Name,$zabbixData) {
try {
$api = new ZabbixApi(...$zabbixData);
} catch (Exception $e) {
// Exception in ZabbixApi catched
echo $e->getMessage();
}
$GetGraphId = $api->graphGet(array(
'output' => 'extend',
'filter' => array('host' => $HostName),
'search' => array('name' => $Name)
));
$ReturnGraphId = $GetGraphId['0']->graphid;
return $ReturnGraphId;
}
这就是我在 symfony 中的功能,我想从数组 $GetGraphId 中获取只有 graphid 的值。重点是在我调用此函数后出现此错误:警告:尝试读取数组上的 属性“graphid”
但是如果我 return 整个数组($GetGraphId)我得到这个:
array:2 [
0 => array:19 [
"graphid" => "some id"
"name" => "Network traffic on tun0"
"width" => "900"
"height" => "200"
"yaxismin" => "0"
"yaxismax" => "100"
"templateid" => "0"
"show_work_period" => "1"
"show_triggers" => "1"
"graphtype" => "0"
"show_legend" => "1"
"show_3d" => "0"
"percent_left" => "0"
"percent_right" => "0"
"ymin_type" => "1"
"ymax_type" => "0"
"ymin_itemid" => "0"
"ymax_itemid" => "0"
"flags" => "4"
]
所以有 graphid 值,但我仍然无法得到它,我真的很感激 clues/ideas/solutions
谢谢!
警告说:尝试读取数组上的 属性“graphid”。您无法使用 object->[=17 访问 graphid =] 符号。请改用此行:
$ReturnGraphId = $GetGraphId['0']['graphid'];
你好
我偶然发现了一个有点简单的问题,但我无法理解也不知道哪里出了问题:
function zabbixGraphGetId($HostName, $Name,$zabbixData) {
try {
$api = new ZabbixApi(...$zabbixData);
} catch (Exception $e) {
// Exception in ZabbixApi catched
echo $e->getMessage();
}
$GetGraphId = $api->graphGet(array(
'output' => 'extend',
'filter' => array('host' => $HostName),
'search' => array('name' => $Name)
));
$ReturnGraphId = $GetGraphId['0']->graphid;
return $ReturnGraphId;
}
这就是我在 symfony 中的功能,我想从数组 $GetGraphId 中获取只有 graphid 的值。重点是在我调用此函数后出现此错误:警告:尝试读取数组上的 属性“graphid” 但是如果我 return 整个数组($GetGraphId)我得到这个:
array:2 [
0 => array:19 [
"graphid" => "some id"
"name" => "Network traffic on tun0"
"width" => "900"
"height" => "200"
"yaxismin" => "0"
"yaxismax" => "100"
"templateid" => "0"
"show_work_period" => "1"
"show_triggers" => "1"
"graphtype" => "0"
"show_legend" => "1"
"show_3d" => "0"
"percent_left" => "0"
"percent_right" => "0"
"ymin_type" => "1"
"ymax_type" => "0"
"ymin_itemid" => "0"
"ymax_itemid" => "0"
"flags" => "4"
]
所以有 graphid 值,但我仍然无法得到它,我真的很感激 clues/ideas/solutions 谢谢!
警告说:尝试读取数组上的 属性“graphid”。您无法使用 object->[=17 访问 graphid =] 符号。请改用此行:
$ReturnGraphId = $GetGraphId['0']['graphid'];