SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: String Replace

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    String Replace

    I have a string:

    16"H Vertical Ladder 2 Legs
    but suppose to be:

    Vertical Ladder 2 Legs

    I tried:

    ereg_replace("[0-9]","",str_replace(""H","",$product_info['products_name']))

    But the problem is that this way it eliminates 2 before Legs as well
    I need eliminate only numbers when they stay together with "H

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2011
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try just this:

    PHP Code:
    $product_info['products_name'] = preg_replace("/[0-9]+"H/"""H"$product_info['products_name']); 

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you


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
  •