Answers for "how to empty array in php"

PHP
1

clear array php

//To clear array you are able to simply re-instantiate it
$foo = array();

//To clear $foo from the symbol table use
unset($foo);
Posted by: Guest on July-15-2020
0

remove empty array elements php

$colors = array("red","","blue",NULL);

$colorsNoEmptyOrNull = array_filter($colors, function($v){ 
 return !is_null($v) && $v !== ''; 
});
//$colorsNoEmptyOrNull is now ["red","blue"]
Posted by: Guest on October-30-2019
1

declare empty array in php

$emptyArray = []; 
$emptyArray = array();
$emptyArray = (array) null;
Posted by: Guest on May-25-2020
0

php create empty array with size

$my_array = array_fill(0, $size_of_the_array, $some_data);
Posted by: Guest on August-13-2021

Code answers related to "how to empty array in php"

Browse Popular Code Answers by Language