views:

47

answers:

2

Hello.

I have an array with integers of values from 0 to 100. I wish to remove integers that are less than number X and keep the ones that are equal or greater than number X.

I am using PHP.

Thanks!

+4  A: 

A little ugly using the clunky create_function, but straight forward:

$filtered = array_filter($array, create_function('$x', "return $x >= $y;"));

For PHP >= 5.3:

$filtered = array_filter($array, function ($x) { return $x >= $y; });

Set $y to whatever you want.

deceze
A: 

Looks like the array_filter function is the one you want.

Alan Storm