If statement based on multiselect values

This might be simple but I am not sure how to go about it.

I have a multiselect field (mainCategories), with values separated by ‘|’, and I need to run an if statement on it to see if it contains any of 3 specific values. What is the best way of doing it? Pseudo code below:

echo 'This page has at least one of Something, Another thing and Yet another selected in the multiselect';

If anyone has any pointers that would be great.

if( count(array_intersect($page->mainCategories()->split('|'), ['something','another-thing','yet-another'])) > 0) {
  // do stuff


Thanks that is working perfectly