我有一个数组array,我做了一个elasticsearch.exceptions.RequestError: TransportError(400,
'illegal_argument_exception', 'Malformed action/metadata line [387],
expected START_OBJECT or END_OBJECT but found [VALUE_STRING]')
,它返回了这个...
print_r
我现在将其写在我的控制器中:
Array (
[0] => Array
(
[0] => Array
(
[cust_id] => xl
[project_id] => central
[tot_ticket] => 1
[person] => jamesbay@example.com )
[1] => Array
(
[cust_id] => tsel
[project_id] => jabo1
[tot_ticket] => 1
[person] => jamesbay@example.com )
[2] => Array
(
[cust_id] => isat
[project_id] => jabo2
[tot_ticket] => 1
[person] => jamesbay@example.com ) ) )
我在获取每个数组的值时遇到问题,这里有人可以帮助我找到解决方案吗?
答案 0 :(得分:1)
您正在尝试使用['cust_id']->cust_id
从对象访问数据,
但您有一个数组,因此可以只使用['cust_id']
。
尝试使用例如foreach:
$test = "";
foreach ($arrays as $data) {
foreach ($data as $value) {
$test .= "<tr>";
$test .= "<td>" . $value["cust_id"] . "</td>";
$test .= "<td>" . $value["project_id"] . "</td>";
$test .= "<td>" . $value["tot_ticket"] . "</td>";
$test .= "<td>" . $value["person"] . "</td>";
$test .= "</tr>";
}
}
echo $test;