I´m facing this issue, probably this is dumb... but here we go:
I have a regular foreach:
foreach $values as $values => $key {
$test[] = $key;
}
of course test is defined outside the loop.
Now, this returns something like this:
array(6) {
[0]=> int(10)
[1]=> int(16)
[2]=> int(10)
[3]=> int(16)
[4]=> int(10)
[5]=> int(16)
[6]=> int(10)
}
However, I need the repeated values to be ignored so test would be like this:
array(2) {
[0]=> int(10)
[1]=> int(16)
}
And new values are only added if and only if, it is not repeated. I already tried array_unique and array_values however I'm not use If I am implementing them bad or what is the issue...
Any help will be appreciated.
Best Regards.
array_unique? Also seein_array.$valuesin your loop, after the loop$valuesbecomes the last element in the array, not the array itself.foreach $values as $values => $keythe worst possible var names ever?