- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$strings = [
"cricket-ck-game-play",
"hand-ball-hb-game-play",
"volley-ball-vb-game-play",
"soccer-sc-game-play"
];
$pattern = "/\b(\w{3,}(?:-(?:\w{3,}))*)-(\w{2})-game-play\b/";
foreach ($strings as $str) {
preg_match($pattern, $str, $matches);
print_r($matches);
}