Blogger Information
Blog 36
fans 1
comment 0
visits 26435
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
实例演示5种PHP数组函数
早晨
Original
791 people have browsed it

代码

  1. <?php
  2. namespace _0811;
  3. echo '----------------------数组函数:array_diff---------------------------------<br>';
  4. $a = ['小明', '小红', '小丽', '小黄'];
  5. $b = ['小蓝', '小明', '小五', '小王'];
  6. print_r(array_diff($a, $b));
  7. echo '<br>----------------------数组函数:array_intersect---------------------------------<br>';
  8. print_r(array_intersect($a, $b));
  9. echo '<br>----------------------数组函数:array_merge---------------------------------<br>';
  10. print_r(array_merge($a, $b));
  11. echo '<br>----------------------数组函数:array_unique---------------------------------<br>';
  12. $c = ['小明', '小红', '小丽', '小黄', '小蓝', '小明', '小五', '小王'];
  13. print_r(array_unique($c));
  14. echo '<br>----------------------数组函数:array_column---------------------------------<br>';
  15. $d = [
  16. ['name' => '小明', 'age' => 18],
  17. ['name' => '小红', 'age' => 22],
  18. ['name' => '小丽', 'age' => 35],
  19. ];
  20. print_r(array_column($d, 'name'));
  21. echo '<br>----------------------数组函数:array_slice---------------------------------<br>';
  22. print_r(array_slice($c, 2, 6));

运行效果

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