Preg match + function

Discussion in 'PHP' started by goscript, Jul 18, 2008.

  1. #1
    Hi,
    I am having a text:

    $text="text text>bla1<text text>bla2<text text>bla3<";
    PHP:
    and a function:
    function edit($x)
    {
    .......
    .......
    return $x;
    }
    
    PHP:
    What I need is to search for all texts between > and < and replace them with edit()

    example:
    replace bla1 with the result of edit("bla1")
    replace bla2 with the result of edit("bla2")
    replace bla3 with the result of edit("bla3")

    I know this can be done with preg_replace , but couldn't figure out exactly how.

    Thanks
     
    goscript, Jul 18, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Jul 18, 2008 IP
    goscript likes this.
  3. goscript

    goscript Prominent Member

    Messages:
    2,753
    Likes Received:
    306
    Best Answers:
    0
    Trophy Points:
    315
    #3
    Thanks nico
     
    goscript, Jul 18, 2008 IP