PHP two-dimensional array to one-dimensional array

Source: Internet
Author: User
{Code ...} how to convert the data to a one-dimensional array? how can I use The select () method of thinkphp to convert the data to a one-dimensional array or do not use select () when querying this data () can other TP methods be used to obtain one-dimensional arrays?
$ Data = array (1) {[0] => array (10) {["account_id"] => string (1) "1" ["account_type"] => string (1) "1" ["account_phone"] => string (11) "18284573042" ["account_password"] => string (32) "33663f%f1195d4e14d357bcd4aac2b" ["account_salt"] => string (20) "acfhjzHIJVW2! # ^) [+ .; "[" Account_alipay "] => string (1)" 0 "[" account_createtime "] => string (1)" 0 "[" account_cash "] => string (1) "0" ["account_name"] => string (9) "Wang Changning" ["account_isdelete"] => string (1) "0 "}}

How to convert to a one-dimensional array
This data is obtained using the select () method of thinkphp.
How can I convert it into a one-dimensional array?
Or can I use other TP methods to obtain a one-dimensional array without using the select () method when querying this data?

Reply content:
$ Data = array (1) {[0] => array (10) {["account_id"] => string (1) "1" ["account_type"] => string (1) "1" ["account_phone"] => string (11) "18284573042" ["account_password"] => string (32) "33663f%f1195d4e14d357bcd4aac2b" ["account_salt"] => string (20) "acfhjzHIJVW2! # ^) [+ .; "[" Account_alipay "] => string (1)" 0 "[" account_createtime "] => string (1)" 0 "[" account_cash "] => string (1) "0" ["account_name"] => string (9) "Wang Changning" ["account_isdelete"] => string (1) "0 "}}

How to convert to a one-dimensional array
This data is obtained using the select () method of thinkphp.
How can I convert it into a one-dimensional array?
Or can I use other TP methods to obtain a one-dimensional array without using the select () method when querying this data?

Take it directly

$data[0]

ThinkPhp method

->first();

But you can talk about your needs. for example, what you get is unique? Or is it just the first response to a pile of data?

Use the find method in the model

You can use foreach to traverse it.

Do not use the select statement of thinkphp. it is used to retrieve multiple records. PHP executes the statement online.

Select () to find ()

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.