Create an assoc array with equal keys and values from a regular array

后端 未结 3 2099
无人共我
无人共我 2020-12-08 18:23

I have an array that looks like

$numbers = array(\'first\', \'second\', \'third\');

I want to have a function that will take this array as

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 18:30

    You can use the array_combine function, like so:

    $numbers = array('first', 'second', 'third');
    $result = array_combine($numbers, $numbers);
    

提交回复
热议问题