The first type: use regular
Copy CodeThe code is as follows: echo Preg_replace (' # # ', ' ', ' ab AB ');
Output "Abab"
?>
The second type: Using the Str_replace () function
Copy CodeThe code is as follows: Echo str_replace (', ', ' ab AB ');
Output "Abab"
?>
The third type: Using the STRTR () function
Copy CodeThe code is as follows: echo strtr (' Ab ab ', array (' ' = ') ');
Output "Abab"
?>
The STRTR () function is somewhat special to use, essentially:
Copy CodeThe code is as follows: STRTR (' Ewb ', ' web ', ' 123 ') = =
STRTR (' Ewb ', Array (' e ' = ' 2 ', ' w ' = ' 1 ', ' b ' = ' 3 ')) = =
Str_replace (Array (' E ', ' W ', ' B '), Array (' 2 ', ' 1 ', ' 3 '), ' ewb ');
?>
Fourth: Using encapsulation functions
Copy the Code code as follows:
function Trimall ($STR)//Delete space
{
$qian =array ("," "," \ T "," \ n "," \ R ");
$hou =array ("," "," "," "," ");
Return Str_replace ($qian, $hou, $STR);
}
http://www.bkjia.com/PHPjc/739776.html www.bkjia.com true http://www.bkjia.com/PHPjc/739776.html techarticle the first: use regular copy code code as follows:? PHP echo Preg_replace (' # # ', ' ', ' ab AB ');//Output "Abab"? The second type: Use the Str_replace () function to copy the code code as follows:?...