PHP array values

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP: array_values() function

PHP: Return all the values of an array

The array_values() function is used to fetch all the values from an array. The function indexes the array numerically.

Version

(PHP 4 and above)

Syntax

array_values(array1)

Parameter

Name

Description

Required /
Optional

Type

array1

Specifies the name of the array.

Required

Array

Return value

Numerically indexed array of values of array1.

Value Type : Array

Pictorial Presentation :

php array array_values() function

Example :

  1. $fruits_list = array('Orange',  'Apple','Banana', 'Cherry');  

  2. print_r(array_values($fruits_list));  

  3. ?>  

Output :

Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry )