As a very amateur coder with only a couple of months experience, I struggled and wrote a script to prevent a smiley flood in a forum. I used substr_count to look for instances of smiley code, but as there were 3 things to look for, substr_count is called 3 times plus an extra call to determine if anyone was posting a code sample, so 4 times in all - which is no doubt extremely inefficient, even though the code works perfectly. As a php beginner, I'm dazzled by the amount of functions available, and I couldn't find an alternative function that could handle 3 searches at once, let alone the 4th.
Could anyone please advise me on a better function that could replace the following statement, and use less overhead
$max_smilies = 10;
if (substr_count($message, ':') + substr_count($message, ';') + substr_count($message, 'B)') > $max_smilies && !substr_count($message, '[code]')) {
// warning code here
Any help would be much appreciated