Actually the most convinient way to do this is by using regular expressions. There are two alternatives:
1) Do not specify the first string as a string but as a regexp-pattern instead, use preg_match
to compare:
$txt1 = '/^TXN: .*? was Failed. Reference no. .*?$/';
$txt2 = "TXN: 452235585 was Failed. Reference no. 452525222. Geeglobia providing best holiday packages. Check it now";
$match = (preg_match($txt1, $txt2) == 1);
2) Convert the first string to a pattern, then do as above.
$txt1 = "TXN: <452235585> was Failed. Reference no. <452525222>";
$txt2 = "TXN: 452235585 was Failed. Reference no. 452525222. Geeglobia providing best holiday packages. Check it now";
$convertedTxt1 = '/^' . preg_replace("/(.*?)<.*?>/", "$1.*?", $txt1) . '$/';
$match = (preg_match($convertedTxt1, $txt2) == 1);
(code snippets untested)