SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP String Functions

PHP case sensitive String Replace

To 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.
<?Php
$string="This is an example on how html is used in 
developing user-friendly web sites. By using HTML  we can
 control the content of a page";

echo $string;
echo "<br><br>";
$string=str_replace("html","PHP",$string);

echo "<b>After replace</b> <br><br>$string";

?>
If you run the above code your will see result like this

This is an example on how html is used in developing user-friendly web sites. By using HTML we can control the content of a page

After replace

This is an example on how PHP is used in developing user-friendly web sites. By using HTML we can control the content of a page




So 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

Be the first to post comment on this article :


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer