Remove any price from a string - +Rep

Discussion in 'PHP' started by emitind, Apr 8, 2010.

  1. #1
    I'm having trouble trying to remove prices (£xxx.xx) from within a string. In other words, I need to find anything within a string from £1.00 to £1111.99 and remove it.

    I suspect I may need to use preg_replace or preg_match however I have not had any luck so far.

    If you have any suggestions I'd be very grateful and will provide rep.

    Thanks
     
    emitind, Apr 8, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    preg_replace('~£([0-9]{1,4})\.([0-9]{2})~', '', $str);
    PHP:
     
    danx10, Apr 8, 2010 IP
    emitind likes this.
  3. emitind

    emitind Peon

    Messages:
    567
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    fantastic, thanks danx10. Rep left.
     
    emitind, Apr 9, 2010 IP