Logo

Programming-Idioms

History of Idiom 63 > diff from v47 to v48

Edit summary for version 48 by programming-idioms.org:
Restored version 46

Version 47

2020-05-13, 23:39:25

Version 48

2020-05-14, 12:26:50

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.
Assume occurrences of y are not overlapping.

Variables
x2,x,y,z
Variables
x2,x,y,z
Extra Keywords
substring substitute
Extra Keywords
substring substitute
Code
$answer = str_replace("flag", "", $answer);
Code
$x2 = str_replace($y, $z, $x);
Doc URL
http://php.net/manual/en/function.str-replace.php
Doc URL
http://php.net/manual/en/function.str-replace.php