PHP case sensitive String ReplaceTo replace a part of the string with another string we will use str_replace function in PHP. This function will replace all the occurrence of the string we target and will replace with the string we supply. Here is an example.
If you run the above code your will see result like this
Here you can see the text html is replace by PHP but HTML is not replaced.
So str_replace() is a case sensitive string replacing function. We can use str_ireplace() to get case insensitive string replacement
Find & ReplaceWe can create an array of search strings and an array or replace strings. These two array we can apply to search and replace words from the content. The matching words will be replace by matching strings from replace array. Original String
Here is the code
Highlighting the changes.Replace the replace array with additional tags to highlight the replaced string.
Read how search & replace is used to change content of a page
Be the first to post comment on this article :