Replace all special character from a string

Hi,
Here is a function which will replace all special character from a string.

We can write a regx to check all character number ,space and – , and we can replace everything with –

[^A-Za-z0-9\- ]

Below is sample for how to replace all special character from a string using regx

$variable = "word";
preg_replace('/[^A-Za-z0-9\- ]/', '-', $variable);

Hope it will help some one

1,362 total views, 3 views today

6 Comments

  1. Yes! Finally someone writes about quest bars.

  2. I enjoy what you guys are usually up too. Such
    clever work and exposure! Keep up the great works guys
    I’ve incorporated you guys to our blogroll.

  3. I appreciate, result in I found exactly what I used to be having a look for.
    You have ended my 4 day long hunt! God Bless you man. Have a nice day.
    Bye

  4. Great post however , I was wanting to know if you could write a litte more on this topic?
    I’d be very grateful if you could elaborate a little bit further.
    Cheers!

  5. Im obliged for the article.Really thank you! Awesome.

  6. A big thank you for your post. Fantastic.

Leave a Reply

Your email address will not be published.

*

© 2017 shabeeb Blog

Theme by Anders NorénUp ↑