Fix an error from 6af9dd6e24687b6a7b9d14a058a47edcac761e61

Related: #4407
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 79aaf14..4f9210f 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -287,7 +287,7 @@
 			elseif (preg_match_all("/{$delim}(".$badword."){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE))
 			{
 				$matches = $matches[1];
-				for ($i = count($matches); $i >= 0; $i--)
+				for ($i = count($matches) - 1; $i >= 0; $i--)
 				{
 					$length = strlen($matches[$i][0]);
 					$str = substr_replace(