Answers for "remove instance from array php"

PHP
0

php remove object from array

unset($array[$key]);

// You can do using function when no key

function unsetValue(array $array, $value, $strict = TRUE)
{
    if(($key = array_search($value, $array, $strict)) !== FALSE) {
        unset($array[$key]);
    }
    return $array;
}
Posted by: Guest on November-02-2020
1

php remove element from array

$arr = array('a' => 1, 'b' => 2, 'c' => 3);
unset($arr['b']);

// RESULT: array('a' => 1, 'c' => 3)

$arr = array(1, 2, 3);
array_splice($arr, 1, 1);

// RESULT: array(0 => 1, 1 => 3)
Posted by: Guest on March-04-2020

Code answers related to "remove instance from array php"

Browse Popular Code Answers by Language