Getting key value pair array in Yii2
<pre><code>$data = User::find()
    -&gt;select('id, name')
    -&gt;where(['status' =&gt; 'active'])
    -&gt;orderBy('id DESC')
    -&gt;asArray()
    -&gt;all();
[
 [0]=&gt;[
        id=&gt;1
        name="test"
      ]
[1]=&gt;[
        id=&gt;2
        name="test1"
      ]
]
</code></pre>

<p>What I want is array which looks similar to this. Mapping the id with name so it can be accessed and checked.</p>

<pre><code>[
[1]=&gt;'test'
[2]=&gt;'test1'
]
</code></pre>