Blogger Information
Blog 38
fans 0
comment 0
visits 18542
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组函数&演示
Blackeye
Original
405 people have browsed it

1

  1. <?php
  2. // 1. array_change_key_case
  3. // 将数组中的所有键名修改为全大写或小写
  4. $arr = ["id"=>"01","name"=>"Dave"];
  5. print_r($arr);
  6. echo "<br/>";
  7. $arr = array_change_key_case($arr, CASE_UPPER);
  8. print_r($arr);
  9. echo "<br/>";
  10. // 2. array_combine
  11. // 创建一个数组,用一个数组的值作为其键名,另一个数组的值作为其值
  12. $id_list = [01,02,03];
  13. $name_list = ["Dave","John","Lee"];
  14. $id_name = array_combine($id_list,$name_list);
  15. print_r($id_name);
  16. echo "<br/>";
  17. // 3. array_keys
  18. // 返回数组中部分的或所有的键名
  19. $arr = [0=>"Dave","php"=>"php.cn"];
  20. print_r(array_keys($arr));
  21. echo "<br/>";
  22. // 4. array_key_first
  23. // 获取指定数组的第一个键
  24. $arr = [0=>"Dave","php"=>"php.cn"];
  25. print_r(array_key_first($arr));
  26. echo "<br/>";
  27. // 5. array_key_last
  28. // 获取一个数组的最后一个键值
  29. $arr = [0=>"Dave","php"=>"php.cn"];
  30. print_r(array_key_last($arr));
  31. echo "<br/>";
  32. // 6. array_intersect
  33. // 计算数组的交集
  34. $arr1=[0,1,2,3];
  35. $arr2=[2,3,4,5];
  36. print_r(array_intersect($arr1,$arr2));
  37. echo "<br/>";
  38. // 7. array_flip
  39. // 交换数组中的键和值
  40. $arr = [0=>"Dave","php"=>"php.cn"];
  41. print_r(array_flip($arr));
  42. echo "<br/>";
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!