PHP array_sum() Function6 Jan 2025 | 1 min read The array_sum( ) function is an inbuilt function of PHP. The array_sum( ) function calculates the sum of values in an array and returns the sum of values in an array as an integer or float. This function was introduced in PHP 4.0.4. SyntaxParameters
ReturnThe array_sum( ) function returns the sum of values. Example 1Output: 130 Example 2Output: 0 Example 3Output: 39.7 Example 4Output: 122.12 Next TopicPhp-array-uasort-function |
The array_rand()function is a inbuilt function in PHP. The array_rand()function is used to fetch one or more random entries from an array. It uses a pseudo-random number generator that is not suitable for cryptographic purposes. This function was introduced in PHP 4.0. Syntax mixed array_rand ( array...
1 min read
The array_intersect_assoc() is used to create an array containing keys and values of the first array whose values (i.e., from the first array) are present in all other arrays, while the index of values is same for all the given arrays. This function was introduced...
1 min read
PHP sizeof() Function The sizeof( ) function is an alias of count( ) function. The sizeof( ) function returns the number of elements in an array. This function was introduced in PHP 4.0. Syntax intsizeof(array, mode); Parameter Parameter Description Is compulsory array Specifies the array to use. compulsory mode Specifies the mode. Possible values: 0 - Default. Does...
1 min read
The array_pad() function is a built-in function of PHP. The array_pad() function inserts a specified number of elements, with a specified value, to an array. This function was introduced in PHP 4.0. Syntax array array_pad ( array $array , int $size , mixed $value ); Parameters Parameter Description Required/Optional array Specifies an array. compulsory size Specifies...
1 min read
PHP range() Function The PHP range( ) function is used to create an array containing a range of elements. The PHP range( ) function returns an array of elements from low to high. This function was introduced in PHP 4.0. Syntax array range ( mixed $start , mixed...
1 min read
This function is used to flip the array with the keys and values. It takes one parameter that is an array. The returned array will contain the flipped elements. The values will be the keys, and the keys will be the values. This function was...
1 min read
It is an inbuilt function in PHP. The array_column() function is used to return the values from a single column in the input array. This function is introduced in PHP 5.5. Syntax array_column(array,column_key,index_key); Parameter Description Is compulsory array Specifies the multi-dimensional array to use compulsory Column_key This parameter may be an integer or a string...
2 min read
The array_product() function is inbuilt function of PHP. The array_product() function calculates the product of an array. This function was introduced in PHP 5.1.0. Syntax number array_product ( array $array ); Parameters Parameter Description Required/Optional array Specifies an array. compulsory Return Type The array_product() function returns the product as an integer or float. Example 1 <?php $prime=array(2,3,5,7); print_r(array_product($prime)); ?> Output: 210 Example 2 <?php $even=array(2,6); print_r($even); print_r(array_product($even)); echo "\n"; $odd=array(7,9); print_r($odd); print_r(array_product($odd)); ?> Output: Array ( ...
1 min read
PHP extract() Function The extract( ) function is an inbuilt function of PHP, and it is used to import variables into the local symbol table from an array. This function was introduced in 4.0. Syntax int extract ( array &$array [, int $flags = EXTR_OVERWRITE [, string $prefix...
1 min read
The array_key_last( ) function is used to get the last key of an array. This function was introduced in PHP 7.3.0 Syntax mixed array_key_last ( array $array ); Parameters Parameter Description Is compulsory array Specifies the array. compulsory Return Values The array_key_last( ) function returns the last key of the array if the array is not...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India