进击的码农

二维数组通过一个键值获取这个数组下面其他键名对应的值

$a = [

            [
                'itemcode' => '222',
                'amount' => 230
            ],

            [
                'itemcode' => '111',
                'amount' => 112
            ],
    ]; 

itemcode值唯一,传itemcode=111,想要得到对应的amount值

echo $a[array_search('111',array_column($a,'itemcode'))]['amount']​

回复

This is just a placeholder img.