How can word boundaries be utilized in PHP regex to ensure accurate number matching within a string?

When using regex to match numbers within a string in PHP, word boundaries (\b) can be utilized to ensure accurate matching. Word boundaries specify the position between a word character (such as letters, digits, or underscores) and a non-word character (such as whitespace or punctuation). By using \b before and after the number pattern in the regex, it ensures that the number is matched as a whole word and not as part of a larger number or word.

$string = "The price is $50.25, but the total comes to $100.50";
preg_match_all('/\b\d+\.\d+\b/', $string, $matches);
print_r($matches[0]);