Welcome to the Cookbook

loading...

8.5.20 filter

array Set::filter ($var, $isArray=null)

Filters empty elements out of a route array, excluding '0'.

$res = Set::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false)));

/* $res now looks like: 
	Array (
	    [0] => 0
	    [2] => 1
	    [3] => 0
	    [4] => Array
	        (
	            [0] => one thing
	            [1] => I can tell you
	            [2] => is you got to be
	            [3] => 
	        )
	)
*/
  1. $res = Set::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false)));
  2. /* $res now looks like:
  3. Array (
  4. [0] => 0
  5. [2] => 1
  6. [3] => 0
  7. [4] => Array
  8. (
  9. [0] => one thing
  10. [1] => I can tell you
  11. [2] => is you got to be
  12. [3] =>
  13. )
  14. )
  15. */