:关于正则和循环的有关问题

WBOY
Release: 2016-06-13 13:42:26
Original
1194 people have browsed it

求助:关于正则和循环的问题
$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;
?>

我的设想应该是这样的:

(1) am1->am2->am3->am4->am5

(2)am1/am2/am3/am4/am5

但是一个效果也没实现,请大家帮忙.谢谢!

------解决方案--------------------
$k = explode(" ,", $v)

第一个参数,多一个空格


------解决方案--------------------

PHP code

echo str_replace(array(',','b'),array('->','m'),$v);
echo "<br>";
echo str_replace(array(',','b'),array('/','m'),$v); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template