note 87058 added to function.preg-replace
| From: | 7r6ivyeo at mail dot com | Date: | Mon, 17 Nov 2008 17:25:20 +0000 |
| Subject: | note 87058 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146631@lists.php.net to get a copy of this message | ||
String to filename:
<?php
function string_to_filename($word) {
$tmp = preg_replace('/^\W+|\W+$/', '', $word); // remove all non-alphanumeric
chars at begin & end of string
$tmp = preg_replace('/\s+/', '_', $tmp); // compress internal whitespace and
replace with _
return strtolower(preg_replace('/\W-/', '', $tmp)); // remove all
non-alphanumeric chars except _ and -
}
?>
Returns a usable & readable filename.
----
Server IP: 208.69.120.35
Probable Submitter: 209.26.192.254
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/87058
Del: integrated -- https://master.php.net/note/delete/87058/integrated
Del: useless -- https://master.php.net/note/delete/87058/useless
Del: bad code -- https://master.php.net/note/delete/87058/bad+code
Del: spam -- https://master.php.net/note/delete/87058/spam
Del: non-english -- https://master.php.net/note/delete/87058/non-english
Del: in docs -- https://master.php.net/note/delete/87058/in+docs
Del: other reasons-- https://master.php.net/note/delete/87058
Reject -- https://master.php.net/note/reject/87058
Search -- https://master.php.net/manage/user-notes.php