array_sum() function in PHP

In this article, we will figure out how to discover the entirety of all cluster components utilizing array_sum() work in PHP?

Given a one dimensional cluster and we need to discover the entirety of all components utilizing PHP.

array_sum() work

It is a work in the capacity of PHP, it returns the entirety of cluster components.

Syntax:

array_sum($array_variable); 

It accepts cluster as contention and returns total everything being equal.

Example:

    Input:
    Array elements: {10, 20, 30, 40, 50}
    Output:
    Sum of all elements: 150

Program:

<?php
    //one dimensional array 
    $arr = array(10, 20, 30, 40, 50);
    //sum of the array elements
    $sum = array_sum($arr);
    echo ("Sum of array elements: " . $sum);
?>

Output:

    Sum of array elements: 150

Leave a Comment

error: Alert: Content is protected!!