PHP: Trim and Filter Array
=> Trim and Filter Array:
$array = array("apple", "", 2, null, -5, " orange ", 10, false, " ");
echo "<pre>";print_r($array);echo "</pre><br>";
// trim the array
$result_2 = array_map('trim',$array);
echo "<pre>";print_r($result_2);echo "</pre><br>";
// Filtering the array
$result = array_filter($array);
echo "<pre>";print_r($result);echo "</pre><br>";
$array = array("apple", "", 2, null, -5, " orange ", 10, false, " ");
echo "<pre>";print_r($array);echo "</pre><br>";
// trim the array
$result_2 = array_map('trim',$array);
echo "<pre>";print_r($result_2);echo "</pre><br>";
// Filtering the array
$result = array_filter($array);
echo "<pre>";print_r($result);echo "</pre><br>";
Comments
Post a Comment