Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php preg_replace()

Options
  • 24-06-2007 1:52pm
    #1
    Registered Users Posts: 673 ✭✭✭


    Hi,

    Im having problems with this piece of code. I need it to replace special characters with "". It is doing it for the first 5 $punc variables listed below but it does remove the $ for some reason. Anyone have an idea why its not working for this character?

    Thanks

    [PHP]
    //insert the article slug
    $my_listing_url=strtolower($business_name); // transform to lowercase
    $punc[0]="/!/";
    $punc[1]="/\"/";
    $punc[2]="/£/";
    $punc[3]="/'/";
    $punc[4]="/€/";
    $punc[5]="/\$/";

    // add any punctuation marks likely to be used in your title

    $my_listing_url=preg_replace($punc,"",$my_listing_url);

    // replace all instances of any punctuation found in the $punc array with ""
    [/PHP]


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    try this
    $punc[5]="/\\$/"; 
    


  • Registered Users Posts: 673 ✭✭✭Bananna man


    YAY!! :D Finally.

    Thats been giving me a headache for damned ages now. Thanks m8


Advertisement