Now, you caught me. After many years hacking PHP, I have never ever needed to know the exact number of times the replacement succeeded. In the use cases I meet (and this applies to Perl as well), the task is always to do the replacement, if it can be done, and leave everything as it was otherwise.
in reply to Re^2: Stupid mistakes I repeatedly make
in thread Stupid mistakes I repeatedly make
As of PHP 4, I can't really think of any straightforward solutions. Maybe, I would use a separate round of pattern matching first to derive the number, if I had to do such thing, but I am sure that other monks more familiar with this aspect of PHP will correct me, if I am wrong.