我想搜索一个关联数组,当我找到一个值时,删除数组的那一部分。
这是我的数组的示例:
Array
(
[0] => Array
(
[id] => 2918
[schoolname] => Albany Medical College
[AppService] => 16295C0C51D8318C2
)
[1] => Array
(
[id] => 2919
[schoolname] => Albert Einstein College of Medicine
[AppService] => 16295C0C51D8318C2
)
[2] => Array
(
[id] => 2920
[schoolname] => Baylor College of Medicine
[AppService] => 16295C0C51D8318C2
)
}
我想做的是在 中找到值16295C0C51D8318C2
,AppService
然后删除数组的那部分。因此,例如,如果该代码要在上述数组上运行,它会清空整个数组,因为逻辑匹配该数组中的所有内容。
到目前为止,这是我的代码:
foreach($this->schs_raw as $object) {
if($object['AppService'] == "16295C0C51D8318C2") {
unset($object);
}
}