在SplHeap类的compare()函数中返回值

"Hello Everybody" in the first note of php manual : splheap class there is example I can't understand the line of return in compare() function of splheap subclass

the line I can't understand

return $values1[0] < $values2[0] ? -1 : 1;

The example :

To have a good idea what you can do with SplHeap, I created a little example script that will show the rankings of Belgian soccer
<?php
/**
* A class that extends SplHeap for showing rankings in the Belgian
* soccer tournament JupilerLeague
*/
class JupilerLeague extends SplHeap 
{
    /**
     * We modify the abstract method compare so we can sort our
     * rankings using the values of a given array
     */
    public function compare($array1, $array2)
    {
        $values1 = array_values($array1);
        $values2 = array_values($array2);
        if ($values1[0] === $values2[0]) return 0;
        return $values1[0] < $values2[0] ? -1 : 1;
    }
}

// Let's populate our heap here (data of 2009)
$heap = new JupilerLeague();
$heap->insert(array ('AA Gent' => 15));
$heap->insert(array ('Anderlecht' => 20));
$heap->insert(array ('Cercle Brugge' => 11));
$heap->insert(array ('Charleroi' => 12));
$heap->insert(array ('Club Brugge' => 21));
$heap->insert(array ('G. Beerschot' => 15));
$heap->insert(array ('Kortrijk' => 10));
$heap->insert(array ('KV Mechelen' => 18));
$heap->insert(array ('Lokeren' => 10));
$heap->insert(array ('Moeskroen' => 7));
$heap->insert(array ('Racing Genk' => 11));
$heap->insert(array ('Roeselare' => 6));
$heap->insert(array ('Standard' => 20));
$heap->insert(array ('STVV' => 17));
$heap->insert(array ('Westerlo' => 10));
$heap->insert(array ('Zulte Waregem' => 15));

Can you help me please to understand this line ??

It's a ternary statement. It means:

if ($values1[0] < $values2[0]) {
    return -1;
} else {
    return 1;
}

The ternary operator is not specific to SplHeap. It's just a general use PHP operator.

It's a conditional ternay operator ?(a ternary if).

How does it works?:

In computer programming, ?: is a ternary operator that is part of the syntax for a basic conditional expression in several programming languages. It is commonly referred to as the conditional operator, inline if (iif), or ternary if.

It originally comes from CPL, in which equivalent syntax for e1 ? e2 : e3 was e1 → e2, e3.

Although many ternary operators are possible, the conditional operator is so common, and other ternary operators so rare, that the conditional operator is commonly referred to as the ternary operator.

Source: Wikipedia

For example, using your code:

return $values1[0] < $values2[0] ? -1 : 1;

It's similar to say:

if($values1[0] < $values2[0]){
     return -1;
}
else{
     return 1;
}

The ? works as a then, and the : works as a else