note 41468 deleted from function.htmlentities by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 11:23:11 +0000 |
| Subject: | note 41468 deleted from function.htmlentities by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189584@lists.php.net to get a copy of this message | ||
Note Submitter: Guillaume Beaulieu
----
Here's a simple script to transform filename with accented character in it into much more
usable unaccented character for a restrictive filesystem.
<?php
$string = htmlentities($stringToModify);
/* Take the first letter of the entity (if you got filename with ([<>] in it the result will
probably remain lookable*/
$string = preg_replace("/\&(.)[^;]*;/", "\\1", $string);
/* Change the whitespace into _*/
$string = preg_replace("/[ ]/", "_", $string);
/* Dance ! */
print $string;
?>