3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $alternative = 'offer_type:buy'; $key = 'category:apartment__location_region:shan-south__offer_type:buy'; $result['key'] = 'offer_type:buy_my'; $keyExactMatch = array_intersect( array($key, $alternative), array($result['key'], substr($result['key'], null, -3)) ); var_dump(array($key, $alternative),array($result['key'], substr($result['key'], null, -3)),$keyExactMatch, !!$keyExactMatch);
Output for 4.3.0 - 7.1.0
array(2) { [0]=> string(62) "category:apartment__location_region:shan-south__offer_type:buy" [1]=> string(14) "offer_type:buy" } array(2) { [0]=> string(17) "offer_type:buy_my" [1]=> string(14) "offer_type:buy" } array(1) { [1]=> string(14) "offer_type:buy" } bool(true)