array_flip() 返回一个反转后的 array,例如 trans 中的键名变成了值,而 trans 中的值成了键名。
说明
array array_flip ( array trans )
array_flip() 返回一个反转后的 array,例如 trans 中的键名变成了值,而 trans 中的值成了键名。
注意 trans 中的值需要能够作为合法的键名,例如需要是 integer 或者 string。如果值的类型不对将发出一个警告,并且有问题的键/值对将不会反转。
如果同一个值出现了多次,则最后一个键名将作为它的值,所有其它的都丢失了。
array_flip() 如果失败返回 FALSE。
实例:
代码如下:
$hills=array("first"=>"data1″,"second"=>"data2″,"third"=>"data1″);
$hills=array_flip($hills); //还原键名
$hills1=array_flip(array_flip($hills));//删除重复
display $hills1
结果是:
data2 data1两个数据.
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
How to fix KB5055523 fails to install in Windows 11?
3 weeks agoByDDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks agoByDDD
Roblox: Dead Rails - How To Tame Wolves
3 weeks agoByDDD
Strength Levels for Every Enemy & Monster in R.E.P.O.
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
2 weeks agoByDDD

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
