$url = 'https://xxxxxxx.com/tag/USA'; $parts = explode('/', $url); $str = end($parts); echo $str; // USA