loading...

Discussion on: PHP 7 - Two useful operators, You Need to Know

Collapse
eruizdechavez profile image
Erick Ruiz de Chavez

Nice! I totally forgot about the spaceship operator, and if you happen to have PHP 7.4, things get even smoother, thanks to arrow functions.

usort($products, fn($p1, $p2) => $p2['price'] <=> $p1['price']);
print_r($products);