Well, if I understand correctly, I believe that's it, you can use a combination of for
and if
to know when to make the changes. Using your example:
$MeuArray = array("PEDRO" ,"PEDRO" ,"PEDRO" ,"PEDRO" ,"JOAO" ,"JOAO", "JOAO", "JOAO");
for ($i=0; $i <count($MeuArray) ; $i++) {
if($MeuArray[$i] == 'PEDRO')
{
// Faça aqui as devidas alterações para PEDRO
// Podes criar um novvo array se desejar
// Para utilizar o array atual $MeuArray[$i]['PEDRO'];
echo "Teste";
}
}
And to get all the names, you would have to have an array with all the names, like the example you posted in $MeuArray
.
Having this array, you can use array_unique
. For example:
$MeuArray = array("PEDRO" ,"PEDRO" ,"PEDRO" ,"PEDRO" ,"JOAO" ,"JOAO", "JOAO", "JOAO");
$result = array_unique($MeuArray);
The example will print:
Array
(
[0] => PEDRO
[1] => JOAO
)
Anything but talk.
Att;