string str_ireplace function - case insensitively replaces the search string with the replacement string
string-str-ireplace-function-in-php.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>string str_ireplace function - case insensitively replaces the search string with the replacement string</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Md Iqbal Hosan">
<meta name="title" content="string str_ireplace function - case insensitively replaces the search string with the replacement string">
<meta name="keywords" content="php, example, code, array, function, str_ireplace, string">
<meta name="description" content="string str_ireplace function - case insensitively replaces the search string with the replacement string">
<style>
h2, h4{background:#ddd; color:#000079;}
h2{ padding:3px; margin:3px; font-size:21px;}
h4{ padding:2px; margin:2px; font-size:17px;}
p{padding:2px; margin:2px; color:#0099fb;}
body{ background:#FFFFFb;}
</style>
</head>
<body>
<h2>string str_ireplace function - case insensitively replaces the search string with the replacement string</h2>
<pre>
<?php
/*
----------------------------
let's make a simple string
---------------------------
*/
$myString = "my seo SEO sEo seO sEO Seo boss is SK Saiful Islam";
echo "<h4>Output of myString in the browser</h4>";
print "<p>$"."myString = {$myString}</p>";
print "<p>string length : ".strlen($myString)."</p>";
/*
-----------------------------------------------------------------------------------
now i want to replace all seo with whitespace by using str_ireplace string function
and i also want that replacement will case insensitive
-----------------------------------------------------------------------------------
*/
$myCaseInsensitiveReplacedString = str_ireplace("seo", "", $myString);
echo "<h4>Output of myCaseInsensitiveReplacedString by using string str_ireplace function</h4>";
print "<p>$"."myCaseInsensitiveReplacedString = {$myCaseInsensitiveReplacedString}</p>";
print "<p>string length : ".strlen($myCaseInsensitiveReplacedString)."</p>";
/*
---------------------------------------------------------------------------------------------
this function also rapidly used in professional programming to replace unwanted data from
website visitos.
---------------------------------------------------------------------------------------------
*/
?>
</pre>
</body>
</html>

No comments:
Post a Comment
leave your comments here..