Questions about regular expressions and loops & lt ;? Php $ v & quot; ab1, ab2, ab3, ab4, ab5 & quot; $ kexplode (& quot;, & quot;, $ v ); foreach ($ kas $ x) {$ x1preg_replace (& quot; | B | & quot;, & quot; m & quot;, $ x); echo $ x1.-& gt; questions about regular expressions and loops
$ V = "ab1, ab2, ab3, ab4, ab5 ";
$ K = explode (",", $ v );
Foreach ($ k as $ x)
{
$ X1 = preg_replace ("| B |", "m", $ x );
Echo $ x1. '-> ';
$ X1 + = $ x1 ."/";
}
Echo $ x1;
?>
My idea is as follows:
(1) am1> am2> am3> am4> am5
(2) am1/am2/am3/am4/am5
However, the effect is not achieved either. please help. thank you!
------ Solution --------------------
$ K = explode (",", $ v)
The first parameter has one more space.
------ Solution --------------------
PHP code
Echo str_replace (array (',', 'B'), array ('->', 'M'), $ v); echo"
"; Echo str_replace (array (',', 'B'), array ('/', 'M'), $ v );