146 of 410 menu

The array_values Function

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

Syntax

array_values(array $array): array

Example

Let's get all the values of the array:

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

Code execution result:

[1, 2, 3, 4, 5]

See Also

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