how to remove elements from a php array
This question already has an answer here:
要获得更清晰的代码,请使用array_filter函数http://fr2.php.net/array_filter
$result = array_filter($result, function($row) {
return $row['Department'] != 'br' || $row['Br_no'] === $row['emp_servicing_bnk'];
});
您可以使用unset()
函数销毁数组中的特定键:
foreach ($data as $key => $row) {
if (/* your condition*/) {
unset($data[$key]);
}
}
Use unset
in php. Something like the following code:
unset($row['emp_servicing_bnk'])
链接地址: http://www.djcxy.com/p/30106.html
上一篇: 删除关联数组的一部分
下一篇: 如何从php数组中删除元素