PHP case in sensitive String Replace
The main difference between str_replace and str_ireplace is str_replace is a case sensitive string replacement and str_ireplace is a case in-sensitive string search and replacement.
str_ireplace function in PHP when applied to a main string, it searches for occurrence of a string and replace them by another string.
This function can take an array as search string and each element of the array if present is replaced by another string. We can try with an example. If you are searching for a simple example then you can see str_replace function. Here is a sample code which takes an array of search words and replaces them by another word within a string.
$search = array("good", "php", "html", "ASP");
As we have seen here we can use an array as search terms and all the elements of the array can be replaced by a replace string. We can also use another array as replacement array and each element is replace by matching element from replacement array, if not element is found then blank string is replaced. Here is the script code for that
$final_string = str_replace($search, "*", "All good sites uses PHP along with HTML or they use ASP and html");
$search = array("good", "php", "html", "asp");
$final_string = str_replace($search, $replace, "All good sites uses PHP along with HTML or they use asp and html");
Number of User Comments : 2
|This tutorial is 1000 times helpful to me. Thanks too much.
But is it possible to show us how you built this form we are posting comments from using Ajax ? just like it is working now ? I mean insert records to database without page refresh using Ajax POST method.
|Just read comment posting tutorial. But the Ajax based script is not yet available to download. You can download the basic one.|