Tuesday 23 September 2014

Str_replace function in php with demo

This str_replace function is used for replacing with other characters as in the existing string. that's why we are using this str_replace.

SYNTAX of STR_REPLACE
str_replace(find,replace,string,count)

this str_replace is used to block some unwanted contents from the main content, for that too we can use this str_replace function. 



for that above syntax, we have explanation for that.

find --> required.  here we have to specify the value that to find.
replace --> required.  here we have to specify the replace value that what we have find.
string --> required. complete string, in this string only the find and replace will works.
count --> optional.  this is optional. this is a variable that will count the no of replacements.


SAMPLE CODE
<?php
$content="2my4edge is a computer based programming blog. 
          Going to focus all kind of latest technology an programming related tutorials.";
echo str_replace("2my4edge","1next2","$content");
?>


str_ireplace function is for case sensitive string. for more details Contact 1nexttwo.googlemail.com

and here we can block unwanted and blocked texts in the content. i hope this is helpful to you. thank you.

3 comments:

© All rights reserved @ 1next2.com