/**
* Remove array Element based on key value
* @param $arr
* @param $key
* @return array
*/
function array_pop_by_key($arr, $key) {
$array_keys = array_keys($arr);
foreach($arr as $array_key => $value) {
if($array_key == $key) {
unset($arr[$key]);
}
}
return $arr;
}
* Remove array Element based on key value
* @param $arr
* @param $key
* @return array
*/
function array_pop_by_key($arr, $key) {
$array_keys = array_keys($arr);
foreach($arr as $array_key => $value) {
if($array_key == $key) {
unset($arr[$key]);
}
}
return $arr;
}
I don't get why you used this line:
ReplyDelete$array_keys = array_keys($arr);
unless you meant to write this:
function array_pop_by_key($arr, $key) {
$array_keys = array_keys($arr);
foreach($arr as $array_keys => $value) {
if($array_key == $key) {
unset($arr[$key]);
}
}
return $arr;
}
which I don't think would make sense , but I'm learning , I might be wrong.