Answers for "how to empty array php"

PHP
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

Browse Popular Code Answers by Language