Home >Backend Development >PHP Tutorial >How to learn PHP array_flip()_PHP tutorial

How to learn PHP array_flip()_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:23:581167browse

How to learn PHP array_flip()

Definition and usage

The array_flip() function returns a reversed array. If the same value appears multiple times, the last key name will be used as its value, and all other key names will be lost.

If the data type of the value in the original array is not string or integer, the function will report an error.

Grammar

array_flip(array)

Parameters

Description

array required. Specifies the input array.

Example

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

Output:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/834960.htmlTechArticleHow to learn PHP array_flip() definition and usage array_flip() function returns a reversed array, if the same value appears multiple times, the last key name will be used as its value, and all other...
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