Array portrait slices, have built-in functions?
An array with many keys, Key1, Key2, ...
I want to create a new array based on a key, that is, all the values that extract a particular key form an array.
Is there a built-in function in PHP?
This is very common. I feel there should be a built-in approach.
is a key to the array, which is sliced vertically.
is to implement the following functions
if (count ($arr) > 0) {
foreach ($arr as $v) {
Array_push ($NEWARR, $v [' key1 ']);
}
}
Is there a built-in method?
------Solution--------------------
Apparently, you're referring to a two-dimensional array.
The array of PHP is nested, not an array of traditional meanings. So it's impossible to predict your operation. Built-in functions
Only to traverse the solution yourself
In general, the source of the array is the database query
The required array is constructed when the query data is read, so there is no need to transpose the arrays.
------Solution--------------------
It's just a few lines of code, and it's not complicated.