- // 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;$i
- {
- if($array[$i]!=$tem)
- tem = $ array[$i];
- }
- return $temarray;
- }
- //Test calling function
- $array = array(aa,bb,aa,3,4,5,5,5,5,bc);
- $arr = formatArray($array);
- print_r($arr);
- ?>
-
-
- 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
TechArticle? // 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...