note 58655 deleted from function.ord by danbrown

From: Date: Tue, 11 Oct 2011 16:10:47 +0000
Subject: note 58655 deleted from function.ord by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183802@lists.php.net to get a copy of this message
Note Submitter: daniel vorhauer ---- 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); }

« previous php.notes (#183802) next »