PHP shares how to delete empty array elements. The code for deleting blank elements in an array using PHP is as follows: functionarray_remove_empty ($ arr, $ trimtrue) {foreach ($ arras $ key $ value) {if (is_array ($ value) {arr is actually used.The code for PHP to delete an array of blank elements is as follows:
- function array_remove_empty(& $arr, $trim = true)
- {
- foreach ($arr as $key => $value) {
- if (is_array($value)) {
- array_remove_empty($arr[$key]);
- } else {
- $value = trim($value);
- if ($value == '') {
- unset($arr[$key]);
- } elseif ($trim) {
- $arr[$key] = $value;
- }
- }
- }
- }
The above code is the specific implementation method for PHP to delete blank elements in the array. I hope you can save the code and add it to your favorites for future use.
The specific code for deleting blank elements in arrays in pluphp is as follows: functionarray_remove_empty ($ arr, $ trim = true) {foreach ($ arras $ key = $ value) {if (is_array ($ value) {arr...