replace Archives - wiki

PHP replace between

In this snippet I am just creating an useful function to replace string in between two string (including the given string )

The replace between function definition

sample function calls

sample 1

Output

<div>W d e f g a x c </div>

 

sample 2

Output

<div>some text  </div>

Using preg_replace()

Output

<div>abc  ddfsdfed </div>

 

ref: http://php.net/manual/en/function.strpos.php,

http://php.net/manual/en/function.substr.php,

http://php.net/manual/en/function.str-replace.php

ref: http://php.net/manual/en/function.preg-replace.php

  Like
By bm on June 24, 2016 | php | A comment?
Tags: , ,