array_values()

array_values() — Return all the values of an array.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

array_values() returns all the values from the array and indexes the array numerically.

Signature

array_values(array $array): array

Parameters

ParameterTypeWhat it takes
$arrayarrayThe array.

Return value

Returns an indexed array of values.

Example

A runnable snippet:

$array = array("size" => "XL", "color" => "gold"); print_r(array_values($array));

Output:

Array ( [0] => XL [1] => gold )

See also

array_keys(), array_combine()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page array_values() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.