+ Reply to Thread
Results 1 to 2 of 2

Thread: Replace multiple instances with single one

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    15

    Replace multiple instances with single one

    I have an auto generated string and elements are sperated by "/__br"
    but sometimes the generated text is like that :
    Code:
    $string = some_stuff_here/__br/__br/__br
    So i wanted to replace these multiple instances with single one
    So i tried :
    Code:
    return preg_replace('/(//__br)+/', '/__br', $string);
    But failed...

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    41
    You should escape your forward slash using a backslash, not another forward slash , so it looks like that :
    Code:
    return preg_replace('/(\/__br)+/', '/__br', $string);

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts