Swap array values with php

后端 未结 11 1147
感动是毒
感动是毒 2020-12-10 23:39

I have an array:

array(
    0 => \'contact\',
    1 => \'home\',
    2 => \'projects\'
);

and I need to swap the \'contact\' with

11条回答
  •  臣服心动
    2020-12-11 00:32

    In PHP 7.1+ syntax, you can use this

    [$Array[$a], $Array[$b]] = [$Array[$b], $Array[$a]];
    

提交回复
热议问题