Summary of the use of the php function str_replace. String replacement. Syntax: stringstr_replace (stringneedle, stringstr, stringhaystack); return value: string function type: data processing content description this function replaces string str with string.
Syntax: string str_replace (string needle, string str, string haystack );
Return value: string
Function type: data processing
Description
This function substitutes str into the haystack string and replaces all needle with str. Mlevine@adtraq.com (11-Apr-1999) pointed out that in PHP 3.0.7, this function has some bugs, and the nadeem@bleh.org (05-Jun-1999) supplement in PHP 3.0.8 version function will return to normal.
Example
Replace % body % with black in the following example
<Php
$ Bodytag = str_replace ("% body %", "black ","");
Echo $ bodytag;
>
Format:
[@ Str_replace ("old content to be replaced", "new character to replace the original content", $ variable name of the content to be replaced)]
[@ Str_replace (array ('Old 1', 'old 2', 'old 3'), array ('New 1', 'New 2', 'New 3 '), $ variable name of the content to be replaced)]
[@ Str_replace (array ('Old 1', 'old 2', 'old 3'), 'New content', $ variable name of the content to be replaced)]
Instance:
Replace multiple-to-one: to replace all
Clear the tag and replace it with null.
[@ Str_replace (array ('
','
'), '', $ Content)]
One-to-one replacement: to replace all
Replace tags
[@ Str_replace ('
','
', $ Content)]
Many-to-many replacement: to replace
Change
, At the same time
In other words
Clear all
Bytes. Syntax: string str_replace (string needle, string str, string haystack); return value: string function type: data processing content description this function substitutes string str...