strip empty space of array elements php code example
Example 1: how to trim white space array in php
$fruit = array(' apple ','banana ', ' , ', ' cranberry ');
$trimmed_array = array_map('trim', $fruit);
print_r($trimmed_array);
Example 2: php remove blank values from array
print_r(array_filter($linksArray, fn($value) => !is_null($value) && $value !== ''));
print_r(array_filter($linksArray, function($value) { return !is_null($value) && $value !== ''; }));
print_r(array_filter($linksArray, create_function('$value', 'return $value !== "";')));