RE: [PHP] Unwanted Characters
use eregi_replace("[asutk]+", '', $string) in this way there will be no such letters as a,s,u,t,k in $string Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Clayton Dukes [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 25, 2001 2:34 PM To: [EMAIL PROTECTED] Subject: [PHP] Unwanted Characters How do I remove unwanted/unprintable characters from a variable? $sometext = "The car ran over my dog" needs to be filtered and reprinted as: "The car ran over my dog" Thanks :-) Clayton Dukes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Unwanted Characters
This doesn't seem to work, have I done something wrong? $sometext = "The car ran over my dog\n"; $thread = ereg_replace("[^[:alnum:][:space:]]", "", $sometext); echo $thread; still prints: The car ran over my dog Thanks, Clayton - Original Message - From: [EMAIL PROTECTED] To: "Clayton Dukes" [EMAIL PROTECTED] Sent: Sunday, February 25, 2001 2:28 AM Subject: Re: [PHP] Unwanted Characters Clayton Dukes wrote: How do I remove unwanted/unprintable characters from a variable? $sometext = "The car ran over my dog" needs to be filtered and reprinted as: "The car ran over my dog" Thanks :-) Clayton Dukes ?php $sometext = "The car ran over my dog"; $thread = ereg_replace("[^[:alnum:][:space:]]", "", $sometext); echo $thread ? will print what you asked - of course you may not want numbers but you get the idea. I do this check on all my user inputs to php scripts- I choose what is allowed not what to deny which makes it easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Unwanted Characters
On 24 Feb 2001 21:31:33 -0800, Clayton Dukes [EMAIL PROTECTED] wrote: How do I remove unwanted/unprintable characters from a variable? $sometext =3D "Th=C0e c=D8ar r=F6=F8an over m=D6y dog" needs to be filtered and reprinted as: "The car ran over my dog" Strip everything which isn't in the list of allowed characters: eregi_replace("[^[:alpha:]]", "", $sometext) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Unwanted Characters
How do I remove unwanted/unprintable characters from a variable? $sometext = "The car ran over my dog" needs to be filtered and reprinted as: "The car ran over my dog" Thanks :-) Clayton Dukes
Re: [PHP] Unwanted Characters
Look at the chr() function - figure out what the character is (number wise) and then do an ereg_replace(chr(),'',$string) (from the hip - you can do a replace with chr() on one of the replaces, I've done it before) --Joe On Sun, Feb 25, 2001 at 12:34:21AM -0500, Clayton Dukes wrote: How do I remove unwanted/unprintable characters from a variable? $sometext = "The car ran over my dog" needs to be filtered and reprinted as: "The car ran over my dog" Thanks :-) Clayton Dukes -- --- Joe Stump, PHP Hacker, [EMAIL PROTECTED] -o) http://www.miester.org http://www.care2.com /\\ "It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Unwanted Characters
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Joe Stump) wrote: Look at the chr() function - figure out what the character is (number wise) and then do an ereg_replace(chr(),'',$string) (from the hip - you can do a replace with chr() on one of the replaces, I've done it before) --Joe On Sun, Feb 25, 2001 at 12:34:21AM -0500, Clayton Dukes wrote: How do I remove unwanted/unprintable characters from a variable? $sometext = "ThÀe cØar röøan over mÖy dog" needs to be filtered and reprinted as: "The car ran over my dog" And you might also want to look at strtr() http://php.net/manual/en/function.strtr.php. You could, I suppose, use it to substitute some character that you know would never legitimately appear in $sometext, then do a straight str_replace() on the string for all occurences of that character. -- CC -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Unwanted Characters
Clayton Dukes wrote: How do I remove unwanted/unprintable characters from a variable? $sometext = "The car ran over my dog" needs to be filtered and reprinted as: "The car ran over my dog" Thanks :-) Clayton Dukes ?php $sometext = "The car ran over my dog"; $thread = ereg_replace("[^[:alnum:][:space:]]", "", $sometext); echo $thread ? will print what you asked - of course you may not want numbers but you get the idea. I do this check on all my user inputs to php scripts- I choose what is allowed not what to deny which makes it easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]