Organizational Research By

Surprising Reserch Topic

Question:To get rid of all white space in an array without looping.



asked Sep 13, 2013 in Java Interview Questions by rajesh
edited Sep 12, 2013
+1 vote
19 views



Related Hot Questions

1 Answer

0 votes

 

   $array = array(5, "   ", 2, NULL, 13, "", 7, "\n", 4, "\t");
   print_r($array);
   $result = array_filter($array, create_function('$a','return preg_match("#\S#", $a);'));                 
   print_r($result);
?>
Array
(
    [0] => 5
    [1] =>    
    [2] => 2
    [3] => 
    [4] => 13
    [5] => 
    [6] => 7
    [7] => 
 
    [8] => 4
    [9] =>     
)
Array
(
    [0] => 5
    [2] => 2
    [4] => 13
    [6] => 7
    [8] => 4
)
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013

...