• PHP Video Tutorials

PHP - Ds Sequence filter() Function


Advertisements

Ds\Sequence::filter() function can create a new sequence using callable to determine which values to include.

Syntax

public abstract Ds\Sequence Ds\Sequence::filter([ callable $callback ] )

Ds\Sequence::filter() function can return a new sequence containing all values for which either a callback returned true, or all values that convert to true if a callback was not provided.

Example 1

<?php 
   $seq = new \Ds\Vector([10, 20, 30, 40, 50]);
   var_dump($seq->filter(function($val) {
      return $val % 4 == 0; 
   })); 
?>

Example 2

<?php 
   $seq = new \Ds\Vector([2, 3, 5, 7, 9, 10]);
   var_dump($seq->filter(function($val) {
      return $val; 
   })); 
?>
php_function_reference.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements