bcamp1973 Posted August 23, 2006 Share Posted August 23, 2006 ok, i want to strip all instances of "\r\n", "\r", "\n","\t" and non-alpha numeric characters from a string. in my searching through the PHP manual there seems to be a lot of options...such as str_replace, preg_replace(), ereg_replace() etc. i need something that's fast an efficient and i'm guessing i'll have to use regex of some form but it's not something i'm very knowledgable of. any suggestions? Quote Link to comment Share on other sites More sharing options...
Caesar Posted August 23, 2006 Share Posted August 23, 2006 Take the reverse approach, only match those characters you want to retrieve. ;-) Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 23, 2006 Share Posted August 23, 2006 i like this approach:[code]<?php$String = preg_replace('|[^a-z0-9]|i', '', $String);echo $String;?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.