String substitution.
Syntax: string str_replace (String needle, String str, String haystack);
return value: String
Function type: Data processing
Content Description
This function converts the string str into the haystack string, replacing all needle with Str. Mlevine@adtraq.com (11-apr-1999) points out that in PHP 3.0.7 version, this function has some bugs, while nadeem@bleh.org (05-jun-1999) supplements in PHP 3.0.8 The function is back to normal.
Usage examples
The following example replaces%body% with black
< PHP
$bodytag = Str_replace ("%body%", "Black", "");
Echo $bodytag;
>
Format:
[@str_replace ("Old content to replace", "new character to replace original content", variable name of the replaced content)]
[@str_replace (' Old 1 ', ' Old 2 ', ' Old 3 '), Array (' New 1 ', ' New 2 ', ' new 3 '), $ replaced by the variable name of the content)]
[@str_replace (Array (' Old 1 ', ' Old 2 ', ' Old 3 '), ' new content ', ' variable name of the replaced content ')]
Instance:
Many-to-one substitution: Want to put all the content in the field
Label removed, replaced with empty
[@str_replace (The Array ('
','
'), ', $Content)]
One-to-one replacement: Want to put all the content in the field
Label Replace
[@str_replace ('
', '
', $Content)]
Many-to-many substitutions: you want to put the content field
Into
, while
Change, put
Clear All
http://www.bkjia.com/PHPjc/364526.html www.bkjia.com true http://www.bkjia.com/PHPjc/364526.html techarticle string substitution. Syntax: string str_replace (String needle, String str, String haystack); Return value: String function type: Data processing content Description This function will string str into ...