How to convert array first value as key and second value as value

前端 未结 2 652
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 03:41

Hi I am working on some array operations.

I need to convert first value of array as key and second value of array as value.

I have one variable $test

2条回答
  •  天涯浪人
    2020-12-19 04:26

    Simple solution using array_map function:

    $result = array_map(function($v){
        return [$v[0] => $v[1]];
    }, $testArray);
    

提交回复
热议问题