Mantis - Quercus
Viewing Issue Advanced Details
4494 major always 04-11-11 23:31 07-27-18 04:09
lionel_hutz12 Apache Tomcat 6.0.29 Server  
Windows  
normal 7  
new 3.2.1  
open  
none    
none  
0004494: substr_count does not provide an accurate count when the search string is repeated in succession
substr_count skips the second instance of the search character(s) when they appear in succession in the searched string. For example, if you are searching for the number of times the character 'a' is present in the searched string and the search string contains "aa" it will only report 1 instance, instead of 2 times.
$diff_string = "aaaaa";
echo "Should produce 5, but only shows (3): " . substr_count($diff_string, "a");
    
Work around for this issue, may be to use:
preg_match_all('/a/', "aaaaa", $chunks);

which accurately prints out 5

Notes
(0005189)
kdecherf   
04-12-11 02:55   
Issue fixed on CC branch.
Patch proposal: https://github.com/CleverCloud/Quercus/commit/4f6f2f4bb3a74d68c374e71f134e8850d99ea370 [^]
(0006844)
Glynn   
07-27-18 04:09   
Thanks for posting a work around, this is still a bug in Resin Pro 4.0.55, was driving me insane.