note 82574 deleted from function.preg-replace by crell

From: Date: Fri, 01 Jul 2022 19:48:12 +0000
Subject: note 82574 deleted from function.preg-replace by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218860@lists.php.net to get a copy of this message
Note Submitter: Michael W ---- 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.

« previous php.notes (#218860) next »