The array_values Function

The array_values function selects all values from an array, discarding the keys.

Syntax

phparray_values(array $array): array

Example

Let's get all the values of the array:

php<?php
  $arr = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5];
  var_dump(array_values($arr));
?>

Code execution result:

php[1, 2, 3, 4, 5]

See Also

  • the array_keys function,
    which returns the keys of an array