php中array_flip数组翻转
array_flip() 函数返回一个反转后的数组,如果同一值出现了多次,则最后一个键名将作为它的值,所有其他的键名都将丢失。
如果原数组中的值的数据类型不是字符串或整数,函数将报错。
Return Values ¶
Returns the flipped array on success and NULL on failure.
Examples ¶
Example #1 array_flip() example
<?php
$trans = array_flip($trans);
$original = strtr($str, $trans);
?>Example #2 array_flip() example : collision
<?php
$trans = array("a" => 1, "b" => 1, "c" => 2);
$trans = array_flip($trans);
print_r($trans);
?>now $trans is:
Array
(
[1] => b
[2] => c
)
千里之行,始于足下。改变现在,就是改变未来。改变未来,从现在开始。

浙公网安备 33010602011771号