PHP Function Array_Values
PHP arrays are a key component of many web applications. They provide a way to create indexed, associative and multidimensional arrays with key-value pairs. Associative arrays in PHP use strings as their indexes while indexed and multidimensional arrays have numeric indexes.
The php function array_values takes an indexed array and returns a new array that has all of the values from that array but with numeric keys starting at zero, retaining the original non-numeric indexes for each value. This makes it possible to have an indexed array of values that are sorted with their original key-value associations, and also allows for map functions to operate on the data without changing the key order.
Aside from the ability to sort an array based on its keys, the array_values() function also has two other parameters that can be used: a list of values to exclude and whether to perform strict matching. This last is useful if you want the indexed array to only return values that have a particular key in them. For example, if you have an array of user ids and you pass the array_values() function with the parameter set to only return those user ids that have the value 'tennis' then it will only return the user ids in the array that have the value 'tennis'.
As you can see there are quite a few different ways to work with an array in PHP, however most of them require the internal pointer for the array to be shifted. For this reason, working with a small array by using functions like current(), reset() and end() is often more performant than using combinations of array_values(), array_pop() and count().