PHP has many predefined functions. Whenever you face a problem and search for a solution there is 90% probablity that you can find a php predefined function to solve your problem. While most functions are supported by PHP 4 there are a few new ones have been introduced by PHP5. Often these functions look identical but they are not, lets take a look at the following functions:
str_ireplace and str_replace both functions take 3 parameters.
Parameter1 : The input string which you want to search
Parameter2 : The string which you want to over write on the search string
Parameter3 : The original String
What is the difference between str_ireplace and str_replace
The str_replacefunction is a case-sensitive which means that it replaces the string that exactly matches the string exactly. it means that if you call the function to replace the string "MFS" with "abc", the function would not replace strings which consist of "mFS","mfs","MfS" because it wouldn't consider them a complete match.
However, the str_ireplace function php is not sensitive-rule and will treat "MFS","mfs","MfS" ..... all combination as a single match. Please not that this fuction is available in PHP 5 only.
Sample : Suppose you have a set of results and there is a search features you want to search all records where "mfs" is present and you want to highlight the string "mfs" with a different color like red.
Please see the code below.