note 58655 added to function.ord
| From: | danielvorhauer at osu1 dot php dot net | Date: | Thu, 10 Nov 2005 20:19:51 +0000 |
| Subject: | note 58655 added to function.ord | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98405@lists.php.net to get a copy of this message | ||
i was happy to find matthews function for replacing those nasty word copy-n-paste characters, but i
did have problems using it, since it is not very performant, when it comes to cleaning large amounts
of text.
therefore i implemented this function as a replacement, which basically does the same job, but only
uses one call to preg_replace - for whom it may concern :)
note: the \xnn values are hex-values of the according ascii-codes, the following implementation
matched my needs - feel free to correct me
function clean_string_input($input)
{
$search = array(
'/[\x60\x82\x91\x92\xb4\xb8]/i', // single quotes
'/[\x84\x93\x94]/i', // double quotes
'/[\x85]/i', // ellipsis ...
'/[\x00-\x0d\x0b\x0c\x0e-\x1f\x7f-\x9f]/i' // all other non-ascii
);
$replace = array(
'\'',
'"',
'...',
''
);
return preg_replace($search,$replace,$input);
}
----
Manual Page -- http://www.php.net/manual/en/function.ord.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58655
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58655&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58655&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58655&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58655&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58655&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58655&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58655&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58655&report=yes
Search -- http://master.php.net/manage/user-notes.php