Answers for "delete eleament in array php]"

PHP
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
3

php erase element from array

foreach ($items as $key =>$item){
  if(condition){
    unset($item[$key]);
  }
}
Posted by: Guest on July-08-2020

Browse Popular Code Answers by Language