|
LPC Library Functions: filter |
|
NAMEfilter() - return a selective sub-array or sub-mapping
SYNOPSISmixed filter( mixed x, string fun, object ob, mixed extra, ... ); mixed filter( mixed x, function f, mixed extra, ...);
DESCRIPTIONfilter() returns an array or mapping holding the items of 'x' which passed sucessfully through the function 'fun' found in object 'ob'. 'x' is an array or mapping; the return type of filter will be the same as that of 'x'. For each element in 'x' the function 'fun' is called using that element as the parameter. When 'x' a mapping, the (key, value) pair is passed to 'fun'. If given, the second parameter 'extra' and following parameters are sent in each call. An object is considered to have passed sucessfully through 'fun' (and hence is included in the return array or mapping) if 'fun' returns 1. In the second form, a single function pointer 'f' replaces the 'fun' and 'ob' parameters. filter() will call 'f' with each element of the array or mapping. If 'x' is not an array or mapping, then 0 will be returned. SEE ALSO |
|
Page design by Frank Jacquette & Tim Hollebeek Copyright (C) 1998 Tim Hollebeek & Frank Jacquette |
|