【PHP】数组键值对互换
<?php $arrays = array("a" => 1, "b" => 1, "c" => 2); print_r(array_flip($arrays)); $arrays = array('a', 'b', '1', 2, 3); print_r(array_flip($arrays)); ?>
对应结果:
Array ( [1] => b [2] => c ) Array ( [a] => 0 [b] => 1 [1] => 2 [2] => 3 [3] => 4 )
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com