Wednesday 15 February 2012

php - Remove items from array without looping -



php - Remove items from array without looping -

is there way eliminate more 1 items array without looping through ?

eg: array(1,3,67, 78, 60 , 5, 34, 68);

i want remove items > 50 @ once

sure, can utilize array_filter:

$array = array_filter(array(1, 3, 67, 78, 60 , 5, 34, 68), function($element) { homecoming $element <= 50; });

the callback function must homecoming true items in array want keep.

php

No comments:

Post a Comment