PHP | Ds\Sequence map() Function Last Updated : 21 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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 sequence. Return Value: This function returns the callback after applying on each value. Below programs illustrate the Ds\Sequence::map() function in PHP: Program 1: php <?php // Create new sequence $seq = new \Ds\Vector( [4, 8, 12, 16] ); // Use map() function and display it var_dump($seq->map(function($val) { return $val * 3; })); ?> Output: object(Ds\Vector)#3 (4) { [0]=> int(12) [1]=> int(24) [2]=> int(36) [3]=> int(48) } Program 2: php <?php // Create new sequence $seq = new \Ds\Vector([12, 15, 18, 20]); // Use map() function and display it var_dump($seq->map(function($val) { return $val / 3; })); ?> Output: object(Ds\Vector)#3 (4) { [0]=> int(4) [1]=> int(5) [2]=> int(6) [3]=> float(6.6666666666667) } Reference: http://php.net/manual/en/ds-sequence.map.php Comment More infoAdvertise with us V vijay_raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_sequence Similar Reads 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 | DsDeque map() Function The Ds\Deque::map() function is an inbuilt function in PHP which is used to return the Deque with each element modified on the basis of operation performed as per the callback function. Syntax: public Ds\Deque::map( $callback ) : Ds\Deque Parameters: This function accepts single parameter $callback 2 min read PHP | DsSet slice() Function The Ds\Set::slice() function is an inbuilt function in PHP which is used to return the sub-set of given range. Syntax: Ds\Set public Ds\Set::slice ( int $index [, int $length ] ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter holds the 2 min read PHP | DsVector map() Function The Ds\Vector::map() function is an inbuilt function in PHP which is used to return the result of a callback after applying to each value in the vector. Syntax: Ds\Vector public Ds\Vector::map( $callback ) Parameters: This function accepts single parameter $callback which is to be applied to each ve 2 min read PHP DsMap sum() Function The Ds\Map::sum() function of PHP is used to get the sum of all of the values present in the Map instance. Syntax: number public Ds\Map::sum ( void ) Parameters: This function does not accepts any parameter. Return value: This function returns the sum of all of the values present in the Map instance 1 min read PHP | DsVector reduce() Function The Ds\Vector::reduce() function is an inbuilt function in PHP which reduce the vector to a single value by applying operations in the callback function. Syntax: mixed public Ds\Vector::reduce( $callback, $initial ) Parameters: This function accepts two parameters as mentioned above and described be 2 min read PHP | DsMap reverse() Function The Ds/Map::reverse() function in PHP is used to in-place reverse the elements of a specified Map instance. That is, the function in-place reverses the order of elements present in the specified Map instance. Syntax: Ds\Map public Ds\Map::reverse ( int $position ) Parameter: This function does not a 2 min read PHP | DsDeque slice() Function The Ds\Deque::slice() function is an inbuilt function in PHP which is used to return a sub-Deque which contains elements of the Deque within the index range. Syntax: public Ds\Deque::slice( $index, $length ) : Ds\Deque Parameters: This function accept two parameters as mentioned above and described 2 min read PHP DsSet reverse() Function The Ds\Set::reverse() function of Ds\Set class in PHP is an inbuilt function which is used to reverse the order of elements present in the Set instance. This function reverses the Set in-place. That is, it does not uses any extra space and updates the original Set instance with reversed values. Synt 2 min read PHP | DsSequence 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 Like