Home  >  Article  >  php教程  >  如何学习PHP array_flip()

如何学习PHP array_flip()

WBOY
WBOYOriginal
2016-06-13 09:29:421179browse

如何学习PHP array_flip()

定义和用法

array_flip() 函数返回一个反转后的数组,如果同一值出现了多次,则最后一个键名将作为它的值,所有其他的键名都将丢失。

如果原数组中的值的数据类型不是字符串或整数,函数将报错。

语法

array_flip(array)

 

参数

描述

 

array必需。规定输入的数组。

 

 

例子

"Dog",1=>"Cat",2=>"Horse");print_r(array_flip($a)); ?>

输出:

Array ( [Dog] => 0 [Cat] => 1 [Horse] => 2 )

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn