note 89139 added to function.str-replace
| From: | JorgeGarza at osu1 dot php dot net | Date: | Tue, 24 Feb 2009 01:58:38 +0000 |
| Subject: | note 89139 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151039@lists.php.net to get a copy of this message | ||
In order to create nicer urls i use this simple function:
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:
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,
----
Server IP: 69.147.83.197
Probable Submitter: 189.143.95.141
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/89139
Del: integrated -- https://master.php.net/note/delete/89139/integrated
Del: useless -- https://master.php.net/note/delete/89139/useless
Del: bad code -- https://master.php.net/note/delete/89139/bad+code
Del: spam -- https://master.php.net/note/delete/89139/spam
Del: non-english -- https://master.php.net/note/delete/89139/non-english
Del: in docs -- https://master.php.net/note/delete/89139/in+docs
Del: other reasons-- https://master.php.net/note/delete/89139
Reject -- https://master.php.net/note/reject/89139
Search -- https://master.php.net/manage/user-notes.php