1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

preg_replace help

Discussion in 'PHP' started by thesurface, Mar 17, 2015.

  1. #1
    How could I replace the name and YYY ZZZ, AA, BBB, etc. for the same number of letters generatedby some string generator? ZZZ example would be replaced by the Qj3 and e.g. DDaa be replaced for hT4y etc...

    
    .-----------------====-------------------------==  ===--.
    |-=[ U S E R T O P ]=---------------.  |
    |  `-----------------====----------|
    |  1 ZZZ/iND  200.3M  14F  46.8%  80461KBs |
    |  2 YYy/iND  70.7M  5F  16.5%  46622KBs |
    |  3 Aa/iND  57.2M  4F  13.4%  49353KBs |
    |  4 BBB/iND  28.6M  2F  6.7%  32796KBs |
    |  5 Ccc/hidden  28.6M  2F  6.7%  67702KBs |
    |  6 DDaa/iND  28.6M  2F  6.7%  63206KBs |
    |  7 DSQ/iND  14.3M  1F  3.3%  12795KBs |
    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
    |  7 Total  428.4M  30F 100.0%  63269KBs |
    `-----================---------------------------==------------------'
    Code (markup):
     
    thesurface, Mar 17, 2015 IP
  2. thewpdev

    thewpdev Well-Known Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #2
    here is the simple preg_replace example that may work for you.
    <?php

    $string = 'ZZZ';
    $pattern = '(Z{3})';
    $replacement = 'Q3j';
    echo preg_replace( $pattern, $replacement, $string );

    ?>
     
    thewpdev, Mar 18, 2015 IP