: Issues related to regular and cyclic

Source: Internet
Author: User
Help: Questions about regular and cyclical
$v = "AB1,AB2,AB3,AB4,AB5";
$k = Explode (",", $v);
foreach ($k as $x)
{
$x 1=preg_replace ("|b|", "M", $x);
echo $x 1. ';
$x 1+= $x 1. " /";
}
echo $x 1;
?>

My idea should be this:

(1) AM1->AM2->AM3->AM4->AM5

(2) AM1/AM2/AM3/AM4/AM5

But one effect is not realized, please help. Thank you!

------Solution--------------------
$k = Explode (",", $v)

First argument, one more space


------Solution--------------------
PHP Code
echo str_replace (Array (', ', ' B '), Array (', ', ' m '), $v);
echo str_replace (Array (', ', ' B '), Array ('/', ' m '), $v);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.