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

查看所有标签

Machine Learning in Action

Machine Learning in Action

Peter Harrington / Manning Publications / 2012-4-19 / GBP 29.99

It's been said that data is the new "dirt"—the raw material from which and on which you build the structures of the modern world. And like dirt, data can seem like a limitless, undifferentiated mass. ......一起来看看 《Machine Learning in Action》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具