If statement based on multiselect values

Hi,
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:

if($page->mainCategories()->contains(['something','another-thing','yet-another']):
echo 'This page has at least one of Something, Another thing and Yet another selected in the multiselect';
endif;

If anyone has any pointers that would be great.

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

https://www.php.net/manual/en/function.array-intersect.php

Thanks that is working perfectly