Php array_flip function

Source: Internet
Author: User

Array_flip
(PHP 4 and PHP 5)

Array_flip-array of organic codes and their related values of the exchange

Description
Array array_flip (array $ Cross)
Array_flip () returns the inverted order in an array, that is, the key is converted into the value concept and the value concept from the opposite to the key.

Note that values need to be valid keys, that is, they must be either integers or strings. Warning if the emission value has an incorrect type, the key/value pair issue will not be flipped.

If a value has several events, the newest key will be used as its own value, and all others will be lost.

Parameters

Reverse
A series of key/value pairs are flipped.


Return value
Returns the array flip success and FALSE failure.

Instance

Example #1 array_flip ()

<? 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 );
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.