You will need a regular expression to match the precise sequence pattern. I suggest this apporach:
<?php
$subject = " test No. 82 and No. 8 more No. 234";
$pattern = '/No\. \d+/';
$offset = 0;
while (preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, $offset+1)) {
$offset = $matches[0][1];
var_dump($matches);
}
The output, which of course can be further processed, is:
array(1) {
[0] =>
array(2) {
[0] =>
string(6) "No. 82"
[1] =>
int(6)
}
}
array(1) {
[0] =>
array(2) {
[0] =>
string(5) "No. 8"
[1] =>
int(17)
}
}
array(1) {
[0] =>
array(2) {
[0] =>
string(7) "No. 234"
[1] =>
int(28)
}
}
Depending on your exact requirements you may want to modify the pattern to '/No\. (\d+)/' to match exactly the numeric parts. You also will have to adapt the offset line to $offset = $matches[1][1]; then obviously.
strposto find a substring after the digits.