Change language

PHP Ds / Set filter () function

|
Syntax:
DsSet public DsSet::filter ($callback)
Parameters: This function takes one parameter $callback,which is optional, and returns True if the value should be included, otherwise False.Returned value: this function returns a new set containing all values ​​for which the callback returned True, or all values ​​that convert to True if no callback was provided.The programs below illustrate the Ds / Set function::filter()in PHP:Program 1:  
// Create a new set $set = new DsSet ([10, 20, 30, 40, 50]);  
// Display the new set using the filter function var_dump ( $set -> filter ( function ( $val ) { return $val % 4 == 0; }));  
?>
Exit:
object (DsSet ) # 3 (2) {[0] = > int (20) [1] = > int (40)}
Program 2:  
// Create a new set $set = new DsSet ([2, 5 , 4, 8, 3, 9]);  
// Display the new set using the filter function var_dump ( $set -> filter ( function ( $val ) { return $val ; }));  
?>
Exit:
object (DsSet ) # 3 (6) {[0] = > int (2) [1] = > int (5) [2] = > int (4) [3] = > int (8) [4] = > int (3) [5] = > int (9)}
Link: https: / /www.php.net/manual/en/ds-set.filter.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method