我希望能够搜索关联数组,当找到一个值时,删除该部分数组。
这是我的一个数组样例:
我希望做的是在
以下是我的代码:
这是我的一个数组样例:
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
)
}
我希望做的是在
AppService
中找到值为 16295C0C51D8318C2
的部分并将其删除。例如,如果该代码在上述数组上运行,则会清空整个数组,因为逻辑匹配该数组中的所有内容。以下是我的代码:
foreach($this->schs_raw as $object) {
if($object['AppService'] == "16295C0C51D8318C2") {
unset($object);
}
}