我正在连接到第三方API可以dd完整结果。作为测试,我为所有国家提供了名称和类型。现在,我只想显示一个国家/地区名称作为测试。我不确定该怎么做。
我尝试了$ countries [0]-> name和$ countries [0] ['name'],但两者似乎都不起作用
当前结果:
array:69 [▼
0 => NamedCriterion {#218 ▼
-name: "Andorra"
-type: "Country"
-value: "13"
}
1 => NamedCriterion {#235 ▶}
2 => NamedCriterion {#233 ▶}
3 => NamedCriterion {#220 ▶}
4 => NamedCriterion {#230 ▶}
5 => NamedCriterion {#223 ▶}
6 => NamedCriterion {#221 ▶}
7 => NamedCriterion {#219 ▶}
通过此通话:
$response = $search->getCriteria([], ['Country'], []);
if (!$response->isError()) {
$criterionSets = $response->getCriterionSets();
$countryCriterionSet = $criterionSets[0];
$countries = $countryCriterionSet->getCriteria();
$resultCount = $response->getResultCount();
}
dd($countries);
}
因此,例如,我将由于通话而得到安道尔(Andorra),并得到该结果。