**Syntax:**

range(first,last,step)

**Parameters:**

- First takes an integer used to specify the first value in the range.
- Last takes an integer used to specify the last value in the range.
- This step is an optional parameter that skips the values present in the range.

Let’s see examples to understand this concept better.

## Example 1:

Let’s create an array in a range from 0 to 10 using range().

**Output:**

We can see that the array is created with elements 0 to 11 associated with keys.

## Example 2:

Let’s create an array in a range from 0 to 10 by skipping 4 using range().

**Output:**

We can see that the array is created with elements 0 to 11 associated with keys by skipping 4 every time.

## PHP array_sum()

array_sum() in PHP is used to return the sum of values present in the array. It takes array_input as a parameter.

**Syntax:**

array_sum(array_input)

**Parameters:**

array_input is the input array with numeric values.

Let’s see examples to understand this concept better.

## Example 1:

Let’s create an array that has elements from 0 to 10 using the range() function and return the sum of elements.

**Output:**

The sum of the elements is 55.

## Example 2:

Let’s create an array that has elements -2,3,4,5,6 using the array() function and return the sum of elements.

**Output:**

The sum of the elements is 20.

## PHP array_product()

array_product() in PHP is used to return the product of values present in the array. It takes array_input as a parameter.

**Syntax:**

array_product(array_input)

**Parameters:**

array_input is the input array with numeric values.

Let’s see examples to understand this concept better.

## Example 1:

Let’s create an array that has elements from 1 to 10 using the range() function and return the product of those elements.

//create an array in a range from 1 to 10

$array_input = range(1,10);

print_r($array_input);

#return product of elements present in the above array

print("Product of elements: ");

print_r (array_product($array_input));

?>

**Output:**

The product of the elements is 3628800.

## Example 2:

Let’s create an array that has elements -2,3,4,5,6 using the array() function and return the product of elements.

//create an array with elements

$array_input = array(2,3,4,5,6);

print_r($array_input);

#return product of elements present in the above array

print("Product of elements: ");

print_r (array_product($array_input));

?>

**Output:**

The product of the elements is 720.

## Conclusion

In this PHP arrays tutorial, we saw how to create an array using the range() function by considering all parameters. Array_sum() in PHP is used to return the total sum of elements, and array_product() in PHP is used to return the product of elements present in the array.