note 64108 added to function.strtr
| From: | joeldeganATyahoo at osu1 dot php dot net | Date: | Fri, 07 Apr 2006 15:49:50 +0000 |
| Subject: | note 64108 added to function.strtr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107526@lists.php.net to get a copy of this message | ||
After battling with strtr trying to strip out MS word formatting from things pasted into forms I
ended up coming up with this..
it strips ALL non-standard ascii characters, preserving html codes and such, but gets rid of all the
characters that refuse to show in firefox.
If you look at this page in firefox you will see a ton of "question mark" characters and
so it is not possible to copy and paste those to remove them from strings.. (this fixes that issue
nicely, though I admit it could be done a bit better)
<?
function fixoutput($str){
$good[] = 9; #tab
$good[] = 10; #nl
$good[] = 13; #cr
for($a=32;$a<127;$a++){
$good[] = $a;
}
$len = strlen($str);
for($b=0;$b < $len+1; $b++){
if(in_array(ord($str[$b]), $good)){
$newstr .= $str[$b];
}//fi
}//rof
return $newstr;
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 66.251.40.246
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.strtr.php
Edit -- http://master.php.net/note/edit/64108
Del: integrated -- http://master.php.net/note/delete/64108/integrated
Del: useless -- http://master.php.net/note/delete/64108/useless
Del: bad code -- http://master.php.net/note/delete/64108/bad+code
Del: spam -- http://master.php.net/note/delete/64108/spam
Del: non-english -- http://master.php.net/note/delete/64108/non-english
Del: in docs -- http://master.php.net/note/delete/64108/in+docs
Del: other reasons-- http://master.php.net/note/delete/64108
Reject -- http://master.php.net/note/reject/64108
Search -- http://master.php.net/manage/user-notes.php