Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

php preg_replace()

  • 24-06-2007 12:52PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    YAY!! :D Finally.

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


Advertisement
Advertisement