Example
$array =array (1,2,3,3)
After the process of processing, once you know and repeat the data, delete,
Finally I need an array, because 3 repeats
Reply to discussion (solution)
Array value 3 also don't?
Array value 3 also don't?
Oh, yes
Array_unique () Ah
$arr = Array (1,2,3,3);
$str = Implode (' ', $arr);
$arrres = Array_unique ($arr);
foreach ($arrres as $k = $v)
{
$num = Substr_count ($str, $v);
if ($num = = 1)
{
$res [] = $v;
}
}
Print_r ($res);
$array = Array (1,2,3,3), $t = Array_diff ($array, Array_keys ( array_filter ( array_count_values ($array), function ($v) {return $v >1;}) ) ; Print_r ($t);
Array
(
[0] = 1
[1] = 2
)
$arr = Array (1,2,3,3);
$str = Implode (' ', $arr);
$arrres = Array_unique ($arr);
foreach ($arrres as $k = $v)
{
$num = Substr_count ($str, $v);
if ($num = = 1)
{
$res [] = $v;
}
}
Print_r ($res);
Thank you for the idea, but the code seems to be simple: $arr = Array (1,2,3,3);
$str = Implode (' ', $arr);
foreach ($arr as $k = $v)
{
$num = Substr_count ($str, $v);
if ($num = = 1) {
$res [] = $v;
}
}
Print_r ($res);
?,
$array = Array (1,2,3,3), $t = Array_diff ($array, Array_keys ( array_filter ( array_count_values ($array), function ($v) {return $v >1;}) ) ; Print_r ($t);
Array
(
[0] = 1
[1] = 2
)
Just like I thought.
$array = Array (1,2,3,3), $t = Array_diff ($array, Array_keys ( array_filter ( array_count_values ($array), function ($v) {return $v >1;}) ) ; Print_r ($t);
Array
(
[0] = 1
[1] = 2
)
Moderator Cow B
Just a little bit easier.
$array = Array (1,2,3,3), $t = Array_diff ($array, Array_keys ( array_diff ( array_count_values ($array), Array (1)) ) ;p rint_r ($t);
$array =array (1,2,3,3);
$a =array_count_values ($array);
$item =array ();
foreach ($a as $k = $v) if ($v ==1) $item []= $k;
Print_r ($item);