1 . Custom print function P
effect:
2.array_clomn() 和array_combine() 和array_values()
Explanation
array_column () returns input
an array of the key column_key
columns, if the optional parameter index_key
, then the input
value of this column in the array will be returned as a value corresponding to the key array.
array_combine ( array
$keys
, array $values
):数组
By using an array of values keys
as the key and used values
as a corresponding value in the array to create an array .
array_values () function returns a given array comprises an array of all the keys, but do not hold the keys.
Example: $ array ARR have such a:
Remove the like corresponding to the id value array name
$ arr = array_column ($ goods, 'name', 'id');
output
$arr = array_combine(array_column($arr,'id'),$arr);
The output is
Key removed name: $ arr = array_values ($ arr) Example scenario (after cycles merge array removed foregoing id keys)