PHP | Ds\Sequence apply() Function Last Updated : 21 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Sequence::apply() function is an inbuilt function in PHP which is used to updates all value of sequence by applying a callback function to each value. Syntax: void abstract public Ds\Sequence::apply ( callable $callback ) Parameter: This function accepts single parameter $callback which is used to apply to each value in the sequence. Return value: This function does not return any parameters. Below programs illustrate the Ds\Sequence::apply() function in PHP: Program 1: php <?php // Create new sequence $seq = new \Ds\Vector([10, 20, 30, 40, 50]); // Use apply() function $seq->apply(function($val) { return $val / 5; }); // Display result print_r($seq); ?> Output: Ds\Vector Object ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 [4] => 10 ) Program 2: php <?php // Create new sequence $seq = new \Ds\Vector([2, 3, 5, 6, 8]); // Use apply() function $seq->apply(function($val) { return $val; }); // Display result var_dump($seq); ?> Output: object(Ds\Vector)#1 (5) { [0]=> int(2) [1]=> int(3) [2]=> int(5) [3]=> int(6) [4]=> int(8) } Reference: https://www.php.net/manual/en/ds-sequence.apply.php Comment More infoAdvertise with us Next Article PHP DsMap Functions Complete Reference R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_sequence Similar Reads PHP | DsDeque apply() Function The Ds\Deque::apply() function is an inbuilt function in PHP which is used to update the values of Deque by performing operations as defined by the callback function. Syntax: public Ds\Deque::apply( $callback ) : void Parameters: This function accepts single parameter $callback which holds the funct 2 min read PHP | DsVector apply() Function The Ds\Vector::apply() function is an inbuilt function in PHP which is used to update all values in the array by applying the callback function to each value of the vector. After this callback, all the values of the vector will get modified as defined in the callback function. Syntax: void public Ds 2 min read PHP | DsSet reduce() Function The Ds\Set::reduce() function is an inbuilt function in PHP which is used to reduce the set to a single value by applying operations using the callback function. Syntax: mixed public Ds\Set::reduce ( callable $callback [, mixed $initial ] ) Parameters: This function accepts two parameters as mention 2 min read PHP | DsSequence apply() Function The Ds\Sequence::apply() function is an inbuilt function in PHP which is used to updates all value of sequence by applying a callback function to each value. Syntax: void abstract public Ds\Sequence::apply ( callable $callback ) Parameter: This function accepts single parameter $callback which is us 1 min read PHP DsMap Functions Complete Reference A Map is a sequential collection of key-value pair which is very similar to the array. The key of a map can be of any type and it is unique. If any value added to the same key in a Map then the map value will replace. It is the efficient Data Structure in PHP 7 to provide the alternative of an array 3 min read PHP DsStack Functions Complete Reference Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). The Ds\Stack uses Ds\Vector internally. Requirements: PHP 7 is required for both extension and the compatibility polyfill. Inst 2 min read PHP | Ds\Sequence apply() Function min read Like