note 81907 added to function.preg-replace
| From: | bifor at free dot fr | Date: | Tue, 18 Mar 2008 23:05:41 +0000 |
| Subject: | note 81907 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137188@lists.php.net to get a copy of this message | ||
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
----
Server IP: 213.246.42.8
Probable Submitter: 88.160.22.187
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/81907
Del: integrated -- https://master.php.net/note/delete/81907/integrated
Del: useless -- https://master.php.net/note/delete/81907/useless
Del: bad code -- https://master.php.net/note/delete/81907/bad+code
Del: spam -- https://master.php.net/note/delete/81907/spam
Del: non-english -- https://master.php.net/note/delete/81907/non-english
Del: in docs -- https://master.php.net/note/delete/81907/in+docs
Del: other reasons-- https://master.php.net/note/delete/81907
Reject -- https://master.php.net/note/reject/81907
Search -- https://master.php.net/manage/user-notes.php