Home  >  Article  >  Backend Development  >  对Thinkphp select的数据集的键改成表里的ID

对Thinkphp select的数据集的键改成表里的ID

WBOY
WBOYOriginal
2016-06-06 20:14:111413browse

Thinkphp select后的数组是一个二维数组,键是从0开始排序的,数组里面是带有ID,现在我要查出来的结果是,一个二维数组,键是数据的ID.

有什么办法呢?

回复内容:

Thinkphp select后的数组是一个二维数组,键是从0开始排序的,数组里面是带有ID,现在我要查出来的结果是,一个二维数组,键是数据的ID.

有什么办法呢?

复制一个数组不行吗

<code><?php $arr = [
        [
            'id' => 1,
            'name' => "Bob",
            'sex' => "男",
        ],
        [
            'id' => 2,
            'name' => "Frank",
            'sex' => "男",
        ],
    ];
    $arr2 = [];
    for ($i=0; $i </code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn