答案是从第三方程序以嵌套数组的形式返回给我的,我需要从所有这些嵌套数组中删除某些不必要的值,只留下必要的值,返回数组的示例如下:
//Controller
public function getDictiEconomic()
{
$economicIsn = 987;
$result = $this->service->getDictiEconomic($economicIsn);
return response()->json([
'economicIsn' => $result,
'code' => 200
]);
}
//Service
public function getDictiEconomic($economicIsn)
{
return $this->oracleBd->getDictiDc($economicIsn);
}
//Oracle procedure
public function getDictiDc($isn)
{
try {
$procedure = $this->pdo->prepare("begin insdyr.web_methods.GetDictiList(:vId, :vCursor); end;");
$procedure->bindParam(":vISN", $isn, PDO::PARAM_INT);
$procedure->bindParam(":vCursor", $cursor, PDO::PARAM_STMT, 10000);
$procedure->execute();
oci_execute($cursor, OCI_DEFAULT);
oci_fetch_all($cursor, $result, 0, -1, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);
oci_free_cursor($cursor);
} catch (\Exception $e) {
throw new SystemException('procedure params invalid for getDictiEconomic ' . $e->getMessage());
}
return $result;
}
{
"economicIsn": [
{
"ISN": "7675677",
"PARENTISN": "976",
"CODE": "9",
"NUMCODE": null,
"SHORTNAME": "tyrtyrtyrtyrtyrtyrt",
"FULLNAME": "rtyrtyrtyrtyrtyrtyrtyrty",
"TABLENAME": null,
"CONSTNAME": "tryrtyrtyryrtyryrtyrty",
"N_KIDS": null,
"ACTIVE": "N",
"UPDATED": "2017-02-03 17:01:31",
"UPDATEDBY": "1",
"USERCONSTNAME": null,
"REFCLASSISN1": null,
"REFCLASSISN2": null,
"REFCLASSISN3": null
},
Следом за ним такой же массив и их может быть неопределенное кол-во, можно unset, но
не могу понять как из-за вложенности и неизвестного кол-ва.
],
"code": 200
}
假设您需要从这个嵌套数组中删除所有“PARENTISN”和“TABLENAME”
从 Laravel 8 开始,有一个助手 Arr::dot() 和 Arr::undot()