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 | Ds\Sequence map() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_sequence Similar Reads PHP | Ds\Sequence allocate() Function The Ds\Sequence::allocate() function is an inbuilt function in PHP which is used to allocate enough memory for required capacity. Syntax: void abstract public Ds\Sequence::allocate ( int $capacity ) Parameter: This function accepts single parameter $capacity which indicate number of capacity allocat 1 min read PHP | Ds\Sequence allocate() Function The Ds\Sequence::allocate() function is an inbuilt function in PHP which is used to allocate enough memory for required capacity. Syntax: void abstract public Ds\Sequence::allocate ( int $capacity ) Parameter: This function accepts single parameter $capacity which indicate number of capacity allocat 1 min read PHP | Ds\Sequence map() Function The Ds\Sequence::map() function is an inbuilt function in PHP which returns the result after applying callback function to each value. Syntax: Ds\Sequence abstract public Ds\Sequence::map( $callback ) Parameter: This function accepts single parameter $callback. The callback apply on each value of se 1 min read PHP | Ds\Sequence map() Function The Ds\Sequence::map() function is an inbuilt function in PHP which returns the result after applying callback function to each value. Syntax: Ds\Sequence abstract public Ds\Sequence::map( $callback ) Parameter: This function accepts single parameter $callback. The callback apply on each value of se 1 min read PHP | Ds\Sequence get() Function The Ds\Sequence::get() function is an inbuilt function in PHP which returns the value at given index. Syntax: mixed abstract public Ds\Sequence::get ( int $index ) Parameter: This function accepts single parameter $index which holds the index to access element. Return value: This function returns th 1 min read PHP | Ds\Sequence get() Function The Ds\Sequence::get() function is an inbuilt function in PHP which returns the value at given index. Syntax: mixed abstract public Ds\Sequence::get ( int $index ) Parameter: This function accepts single parameter $index which holds the index to access element. Return value: This function returns th 1 min read Like