Array portrait slices, with built-in functions, what to do with

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.