Blogger Information
Blog 250
fans 3
comment 0
visits 323147
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组函数:array_flip()的作用
梁凯达的博客
Original
1052 people have browsed it

<?php
 //array_flip()
 //函数功能用于将数组的键和值对调
 //参数是一个数值
 //返回值是一个新的数组

实例

 $arr = array(
  '丁a'=>'丁1',
  '丁s'=>'丁2',
  '丁d'=>'丁3',
  '丁f'=>'丁4',
  '丁g'=>'丁5'
 );
 $new_arr = array_flip($arr);
 var_dump($new_arr);
 echo '<hr />';
 //利用自定义函数的方式完成函数;
 function myflip($arr = array()){
  $news_arr = array(); 
  foreach($arr as $key=>$value){
   $news_arr[$value] = $key;
  }
  var_dump($news_arr);
 }
 myflip($arr);

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post