note 89139 deleted from function.str-replace by philip
| From: | philip@php.net | Date: | Wed, 07 Oct 2009 07:55:32 +0000 |
| Subject: | note 89139 deleted from function.str-replace by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161441@lists.php.net to get a copy of this message | ||
Note Submitter: Jorge Garza
----
In order to create nicer urls i use this simple function:
<?php
function niceURL($string)
{
$que = array(
'á','é','Ã','ó','ú','Ã','Ã','Ã','Ã','Ã','ñ','Ã','
' );
$por = array(
'a','e','i','o','u','A','E','I','O','U','n','n','-'
);
return strtolower( str_replace( $que,$por,$string ) );
}
?>
For string "Hello Cruel World"
This will return "hello-cruel-world"
However once i wrote this:
<?php
function niceURL($string)
{
//changing the place of ' ' by '-' to the begining
$que = array( '
','á','é','Ã','ó','ú','Ã','Ã','Ã','Ã','Ã','ñ','Ã'
);
$por = array(
'-','a','e','i','o','u','A','E','I','O','U','n','n'
);
return strtolower( str_replace( $que,$por,$string ) );
}
?>
And for "Hello Cruel World"
This will return "hellocruelworld"
I have no idea why but it made me crazy for a while,