Re: Unwanted Characters

From: Date: Sun, 25 Feb 2001 07:28:30 +0000
Subject: Re: Unwanted Characters
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41558@lists.php.net to get a copy of this message
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" > > Thanks :-) > Clayton Dukes <?php $sometext = "ThÀe cØar röøan over mÖy 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.

« previous php.general (#41558) next »