Level 73
That is good enough. You might consider using numeric values that references the like or dislike though. It will take up less pace in the database.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
$type equals "Like" or "Dislike" I want the counterpart.
// This works just fine but I feel like there's a sexier way...
$counterpart = ($type == "Like") ? 'Dislike' : 'Like';
This will work as well
$counterpart = ['Like', 'Dislike'][$type === 'Like'];
and in your example parentheses are not required
$counterpart = $type == 'Like' ? 'Dislike' : 'Like';
Please or to participate in this conversation.