This question already has an answer here:
- Remove duplicate items from an array 9 answers
Here is the situation:
There are thousand of data. But not all of that are unique. The first foreach
loop is unique. So, I am putting the size in a Array
. Next loop might have same size. So, I am checking the size
of a variable
. If the size found in the Array
, that means its not unique otherwise the size of that variable would be in the Array
. The problem is I'm getting common and unique (both) size in the Array.
PHP Code:
$counter = array();
foreach ($result_all as $data){
$message = $data['msg'];
$size_of_message = strlen($message);
if(contains($message,$chittagong)){
if(empty($counter)){
$counter[] = $size_of_message;
}else{
foreach($counter as $a) {
if ($size_of_message !== $a)
$counter[] = $size_of_message;
}
}
}
}
Result:
Array
(
[0] => 153
[1] => 122
[2] => 165
[3] => 165
)
The result I am expecting:
Array
(
[0] => 153
[1] => 122
[2] => 165
)
</div>