A simple and minimal example:
Text File
ID|NOME|TELEFONE0|ENDERECO|REFERENCIA
ID|NOME|TELEFONE1|ENDERECO|REFERENCIA
ID|NOME|TELEFONE2|ENDERECO|REFERENCIA
ID|NOME|TELEFONE0|ENDERECO|REFERENCIA
PHP code:
<?php
$item = file("arquivo.txt");
$items = array_map(function($line)
{
return explode("|", $line);
}, $item);
$repeat = array();
foreach($items as $it)
{
$repeat[$it[2]] =
isset($repeat[$it[2]])
? (++$repeat[$it[2]])
: 1;
}
$select = array_filter($repeat, function($item){
return $item > 1;
});
foreach($select as $s) echo $s;
Exit:
In other words, it counts the phones that are repeated and shows you which ones are repeated, it is a very simple way, that can be changed, but, the intention is to show some logic that can be adequate to its final code.
Ideone example
A function can be created to have a simple code of all this, example:
<?php
$item = file("arquivo.txt");
function item_telefone_repetido($item)
{
$items = array_map(function($line)
{
return explode("|", $line);
}, $item);
$repeat = array();
foreach($items as $it)
{
$repeat[$it[2]] =
isset($repeat[$it[2]])
? (++$repeat[$it[2]])
: 1;
}
$select = array_filter($repeat, function($item){
return $item > 1;
});
return $select;
}
echo '<pre>';
print_r(item_telefone_repetido($item));
echo '<pre>';
I mean, now just call the function item_telefone_repetido
and pass the array
of values.