$search = "php";
$replace="JavaScript";
$final_string = str_ireplace($search, $replace, "Sites uses PHP along with HTML");
echo $final_string;
Output is here
Sites uses JavaScript along with HTML
Syntax
str_ireplace(search,replace,main_string,count);
search
:replace
:main_string
:count
:
$search = array("good", "php", "html", "ASP");
$final_string = str_replace($search, "*", "All good sites uses PHP along with HTML or they use ASP and html");
echo $final_string;
Output is here
All * sites uses PHP along with HTML or they use * and *
$search = array("server", "php", "JSP", "asp");
$replace=array("client","HTML","JavaScript","CSS");
$final_string = str_ireplace($search, $replace, " Server side scripts are jsp, PHP and ASP ");
echo $final_string;
Output is here
client side scripts are JavaScript, HTML and CSS
$search = array("server", "php", "JSP", "asp");
$replace=array("client","HTML","JavaScript","CSS");
$final_string = str_ireplace($search, $replace, " Server side scripts are jsp, PHP and ASP ",$count);
echo $final_string;
echo "<br>Number of replacement= $count ";
Output is here
client side scripts are JavaScript, HTML and CSS
Number of replacement= 4
John Komla | 19-09-2009 |
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. Thank you, John |
smo | 20-09-2009 |
Just read comment posting tutorial. But the Ajax based script is not yet available to download. You can download the basic one. |