Monday, 16 November 2015

12_substr_replace()

substr_replace()


It takes four argument … 1st :- String to which we want to look out , 2nd:-String which we want to replace , 3rd :- where we want to start, 4th :- Where we want to end.


This function is combination of substr() and str_replace() function


Replacing a part of string.


< ? php
$harshu1= “This part don\’t search. This part Search”;
$harshu_new=substr_replace($harshu1,”HARS”,29,4);
// 1:- String name, 2:- replace string, 3:- where to start, 4:- length of characher
echo $harshu_new; ? >


PART IS REPLACE BY HARS, size of PART IS 4 and HARS is also 4.



No comments:

Post a Comment