note 82574 added to function.preg-replace

From: Date: Wed, 16 Apr 2008 22:35:58 +0000
Subject: note 82574 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-138386@lists.php.net to get a copy of this message
For filename tidying I prefer to only ALLOW certain characters rather than converting particular ones that we want to exclude. To this end I use ... <?php $allowed = "/[^a-z0-9\\040\\.\\-\\_\\\\]/i"; preg_replace($allowed,"",$str)); ?> Allows letters a-z, digits, space (\\040), hyphen (\\-), underscore (\\_) and backslash (\\\\), everything else is removed from the string. ---- Server IP: 202.89.58.1 Probable Submitter: 202.20.3.77 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/82574 Del: integrated -- https://master.php.net/note/delete/82574/integrated Del: useless -- https://master.php.net/note/delete/82574/useless Del: bad code -- https://master.php.net/note/delete/82574/bad+code Del: spam -- https://master.php.net/note/delete/82574/spam Del: non-english -- https://master.php.net/note/delete/82574/non-english Del: in docs -- https://master.php.net/note/delete/82574/in+docs Del: other reasons-- https://master.php.net/note/delete/82574 Reject -- https://master.php.net/note/reject/82574 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138386) next »