PHP removes the specified value from the array
?
One-dimensional arrays
?
Simple way? unset ($arr [Array_search ($value, $arr)])
?
?
$arr = Array ("A", "B", "C", "D");
function Ishave ($var) {?
? if ($var! = "B")?
? return true;?
} ?
$arr _filter = array_values (Array_filter ($arr, "Ishave"));?
Print_r ($arr _filter);?
?
while ($folder = current ($folders)) {?
? ? if ($folder = = $cur _folder) {?
? ? ? ? $KV = key ($folders);?
? ? ? ? Unset ($folders [$kv]);?
? ? } ?
? ? Next ($folders);?
} ? ? ? ??
?
A two-dimensional array?
Function Killarray (& $a, $b, $c) {?
? ? foreach ($a as $key = = $value) {?
? ? ? ? if (Isset ($value [$b]) && ($value [$b]== $c)) {?
? ? ? ? ? ? unset ($a [$key]);?
? ? ? ? } ?
? ? } ?
} ?
$a =array (array (' ID ' =>1, ' num ' =>10, ' type ' = ' news '), array (' ID ' =>2, ' num ' =>100, ' type ' = ' pic '));?
$b = "id";?
$c = "1";?
Killarray ($a, $b, $c);?
Print_r ($a);??
?