Return most common items in list
Skip to the Dramatic Update for the best solution
I was curious how to do this myself, because I could clearly tell there had to be an easier way! I started from scratch and I think I've found exactly what this question is asking for.
I don't normally just rewrite code, but since the question asks the best way, I believe I'm obligated to share what I believe is the &quot;bets way&quot;.
$input = [1, 10, 11, 12, 11, 12, 18, 18];

$recorded = array_count_values($input);

arsort($recorded);

$output = [];

foreach ($recorded as $key =&gt; $value) {
    if ($value == max($recorded)) {
        array_push($output, $key);
    }
}

print_r($output);

I'll explain what's happening here:

We receive the input in $input
array_count_values() returns an array using the values of array as keys and their frequency in array as values. In our case, from $input.
arsort — Sort an array in reverse order and maintain index association
Loop over each pair in the newly sorted array. Create some variables to reference the current pair.
If the current value is equal to the largest value from $recorded
Add that key to the output!

And there we have it!
Update to increase performance
$input = [1, 10, 11, 12, 11, 12, 18, 18];

$recorded = array_count_values($input);

arsort($recorded);

$output = [];

$maximum = max($recorded);

foreach ($recorded as $key =&gt; $value) {
    if ($value == $maximum) {
        $output[] = $key;
    } else if ($value &lt; $maximum) {
        break;
    }
}

print_r($output);

We've stored the maximum so we aren't checking every iteration, and we're checking for a value less than the maximum so we can break out of the loop to prevent going through the whole array.
Dramatic Update
So, I completely missed the array_keys function, as pointed out by shudder. The newly improved code would look something like:
$input = [1, 10, 11, 12, 11, 12, 18, 18];

$recorded = array_count_values($input);

$output = array_keys($recorded, max($recorded));

print_r($output);

Crazy improvement compared to the OPs original code!