note 81907 deleted from function.preg-replace by nlopess
| From: | nlopess@php.net | Date: | Wed, 19 Mar 2008 19:24:56 +0000 |
| Subject: | note 81907 deleted from function.preg-replace by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137211@lists.php.net to get a copy of this message | ||
Note Submitter: bifor at free dot fr
----
Transform a sentences with accents into a nice "link"
<?php
function nicelink($t) {
$arrayaccent = array('-',"
",'é','è','ê','ë','î','ï','ç');
$arraynoaccent =
array('--','-','e','e','e','e','i','i','c');
$t = str_replace($arrayaccent,$arraynoaccent,strtolower($t));
return preg_replace('#[^a-z|0-9|-]#','$1',$t);
}
echo nicelink('héhéhé how are you?');
?>
This example will return hehe-how-are-you