<?php
function returnNumberFromLastWord($str) {
$lastWord = array_pop( explode( ' ', $str ) );
if( false !== strpos( $lastWord, '>' ) ){
$lastWord = substr( $lastWord, strpos( $lastWord, '>' ) + 1 );
}
$number = filter_var( $lastWord, FILTER_SANITIZE_NUMBER_INT );
return substr( $number, strlen( $number ) - 14 );
}
//////////////////////////////////////////////////////////////////////////////////////
$a = '159111/08/199915 -BPOSS CS PG1 1>400010516305897TEXTYU';
$b = 'IVAN PUPKOV 1179010/27/2011HOLD-BMAN/DEL CS PG0100010515465174LIALIA';
echo $a, '<br>';
echo returnNumberFromLastWord($a);
echo '<br>';
echo $b, '<br>';
echo returnNumberFromLastWord($b);