I can’t find a way to read variables in a URL or in a vector or in text form so that it returns just the value which is repeating. In the case that it is only one value, I need to display it, or in the case there are all different values, I need to display all of them.
For example if I have 1,2,3,1,4, I would like it to display 1, and if I have 1,2,3,4 to display all of them.
$values = $_GET['intrebare'];
$count = count($values);
foreach($values as $val =>$array)
{
//echo $val . '<br/>';
//var_dump($array);
if(is_array($array))
{
var_dump($array);
}
else
{
echo $val;
}
}
you can use array_unique on your input array to see if there are no doubles. If an array after array_unique is just as large as before, you should print all values.
From what I understand, if the array does not contain all unique values, you want to print all that occur multiple times. If you only want to print values that occur more than once you can first check with array_count_values what values occur more than once and print them.
The rest is up to you 🙂