PHP two-dimensional array to convert one-dimensional arrays

Source: Internet
Author: User
Tags php online
$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) "33863f368f1195d4e14d357bcd4aac2b"    ["account_salt"] => string(20) "acfhjzHIJVW2!#^)[+.;"    ["account_alipay"] => string(1) "0"    ["account_createtime"] => string(1) "0"    ["account_cash"] => string(1) "0"    ["account_name"] => string(9) "汪昌宁"    ["account_isdelete"] => string(1) "0"  }}

How to convert to a one-dimensional array
I got this data using the thinkphp Select () method.
In what way to convert him into a one-dimensional array
Or, when querying this data, do not use the Select () method to get a one-dimensional array with other TP methods?

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) "33863f368f1195d4e14d357bcd4aac2b"    ["account_salt"] => string(20) "acfhjzHIJVW2!#^)[+.;"    ["account_alipay"] => string(1) "0"    ["account_createtime"] => string(1) "0"    ["account_cash"] => string(1) "0"    ["account_name"] => string(9) "汪昌宁"    ["account_isdelete"] => string(1) "0"  }}

How to convert to a one-dimensional array
I got this data using the thinkphp Select () method.
In what way to convert him into a one-dimensional array
Or, when querying this data, do not use the Select () method to get a one-dimensional array with other TP methods?

Take it straight.

$data[0]

Thinkphp method

->first();

But can you say what you want, like what you've got? Or do you just want the first piece of information?

Using the Find method in the model

You can use foreach to iterate through

Do not use the thinkphp Select, which is to take multiple records, PHP online execution

Select () instead of find ()

  • 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.