Home > Backend Development > PHP Tutorial > PHP function to delete the same elements in an array_PHP tutorial

PHP function to delete the same elements in an array_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:40:54
Original
956 people have browsed it

  1. // Delete the same elements in the array and keep only one same element
  2. function formatArray($array)
  3. {
  4. sort($array);
  5. $tem = ;
  6. $temarray = array();
  7. $j = 0;
  8. for($i=0;$i
  9. {
  10. if($array[$i]!=$tem)
  11.                                                                                       tem = $ array[$i];
  12. }
  13. return $temarray;
  14. }
  15. //Test calling function
  16. $array = array(aa,bb,aa,3,4,5,5,5,5,bc);
  17. $arr = formatArray($array);
  18. print_r($arr);
  19. ?>
  20. I hope the above example can be helpful to everyone.
http://www.bkjia.com/PHPjc/486182.html

www.bkjia.com
true

http: //www.bkjia.com/PHPjc/486182.html

? // Delete the same elements in the array and keep only one same element function formatArray($array) { sort($ array); $tem = ; $temarray = array(); $j = 0; for($i=0;$icount($array);$i ) { if...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template