Php deletes the same element from the array and retains only one element. php Array
<? Php
// Delete the same element from the array and retain only one element.
Function formatArray ($ array)
{
Sort ($ array );
$ Tem = ";
$ Temarray = array ();
$ J = 0;
For ($ I = 0; $ I <count ($ array); $ I ++)
{
If ($ array [$ I]! = $ Tem)
{
$ Temar (www.111cn.net) ray [$ j] = $ array [$ I];
$ J ++;
}
$ Tem = $ array [$ I];
}
Return $ temarray;
}
// Test the call Function
$ Array = array ('A', 'bb ', 'AA', 3,4, 5, 5, 5, 'bc ');
$ Arr = formatArray ($ array );
Print_r ($ arr );
?>
From: http://www.111cn.net/phper/php/63531.htm
Delete a specified duplicate element from a two-dimensional php array and retain only one
Array_unique ($ array); duplicate values can be removed directly.
Php deletes the same element from the array
Array_unique ($ str );
Use this function to directly Delete the same value