- substr: documentation ( source)
- var_dump: documentation ( source)
- array_intersect: documentation ( source)
<?php
$alternative = 'offer_type:buy';
$key = 'category:apartment__location_region:shan-south__offer_type:buy';
$result['key'] = 'category:apartment__offer_type:buy_my';
$keyExactMatch = !!array_intersect(
array($key, $alternative),
array($result['key'], substr($result['key'], null, -3))
);
var_dump($keyExactMatch);