Strip non alphanumeric characters from a string but leave white space
I like to keep little code snippets handy where i can find them. This morning i wanted to create an RSS file from mySQL database content. I needed to remove all of the nasty commas, colons and question marks that would corrupt the rss feed. this little code snippet did the job by stripping out all of the non alpha numeric characters whilst leaving the white space intact .
|
1 |
<?php echo preg_replace("/[^a-zA-Z]/", "", $string); ?> |
Tweeeeets
Latest Updates
Web design Scotland
We are a web design and development company based in Stirling, Scotland .
We think WordPress is rather nice and enjoy the open source goodness of PHP and mySQL.
We pride ourselves on our quality, affordable Website design and development.
Give us a buzz on 01786 489666 or email us here for a quote.
Get In Touch
Farmore IT Ltd
44 Quakerfield
Bannockburn
FK7 8HZ
Scotland



