PHP array_flip() 函数

PHP 教程 · 2019-01-22 08:11:26

实例

反转数组中的键名和对应关联的键值:

<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$result=array_flip($a1);
print_r($result);
?>

定义和用法

array_flip() 函数用于反转/交换数组中的键名和对应关联的键值。

语法

array_flip(array);

参数 描述
array 必需。规定需进行键/值对反转的数组。

技术细节

返回值: 如果反转成功,则返回反转后的数组。如果反转失败,则返回 NULL。
PHP 版本: 4+

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

The Nature of Code

The Nature of Code

Daniel Shiffman / The Nature of Code / 2012-12-13 / GBP 19.95

How can we capture the unpredictable evolutionary and emergent properties of nature in software? How can understanding the mathematical principles behind our physical world help us to create digital w......一起来看看 《The Nature of Code》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试