I have an array with several dynamic names that can change every moment, what is the most correct way to go through this array and create a condition to exclude them from iguail? (in this case two elements with the same name)
I have seen something similar here but it was for fixed elements, I wanted to create a condition in which I gave unset (command to remove an element from the array) in the repeated element, an example of what I want more or less below: / p>
$array = ('pepsi','Coca','fanta','pepsi');
// verificaria se tem elemento igual
if( "a operação que estou na duvida"){
//daria unset em um dos valores duplicados
unset($array["3"]);
}
// uso pra ignorar as chaves do array e alinhar
$array = array_values( $array );
Note: The values are only for example, my array can have n
values.