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);
?>
$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
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》 这本书的介绍吧!