[PHP 4, PHP 5, PHP 7, PHP 8]
array_values — Return all the values of an array
Description
array_values[array $array
]: array
Parameters
array
The array.
Return Values
Returns an indexed array of values.
Examples
Example #1 array_values[] example
The above example will output:
Array [ [0] => XL [1] => gold ]
See Also
- array_keys[] - Return all the keys or a subset of the keys of an array
- array_combine[] - Creates an array by using one array for keys and another for its values
biziclop at vipmail dot hu ¶
8 years ago
Remember, array_values[] will ignore your beautiful numeric indexes, it will renumber them according tho the 'foreach' ordering:
nopy at users dot sourceforge dot net ¶
18 years ago
Just a warning that re-indexing an array by array_values[] may cause you to reach the memory limit unexpectly.
For example, if your PHP momory_limits is 8MB,
and says there's a BIG array $bigArray which allocate 5MB of memory.
Doing this will cause PHP exceeds the momory limits:
It's because array_values[] does not re-index $bigArray directly,
it just re-index it into another array, and assign to itself later.
abimaelrc ¶
11 years ago
This is another way to get value from a multidimensional array, but for versions of php >= 5.3.x
bluej100 at gmail dot com ¶
15 years ago
Most of the array_flatten functions don't allow preservation of keys. Mine allows preserve, don't preserve, and preserve only strings [default].
chrysb at gmail dot com ¶
14 years ago
If you are looking for a way to count the total number of times a specific value appears in array, use this function:
This should really be a native function of PHP.
Anonymous ¶
18 years ago
code till dawn! -mark meves!
How do I get all the values of an array?
How do you get a specific value from an array in PHP?
How do I echo an array in PHP?
'; print_r[$array]; echo '';.