Citat:
Originally posted by thorsell@Mar 4 2007, 16:08
Jajamensan, har även lite andra alternativ till den funktionen:
Kod:
<?php
define( "UC_CHARS", "ĀÁÂÃÄÅÆĮČÉĘËĖÍÎĪĐŅŌĶÔÕÖØŲÚÛÜŨŪ" ); // If you need more, add
define( "LC_CHARS", "āáâãäåæįčéęëėíîīđņōķôõöøųúûüũū" ); // If you need more, add
define( "WORD_SEPARATORS", chr(9).chr(10).chr(11).chr(12).chr(13).chr(32) );
function strtolower2($value) {
*return (
* strtolower(
* * strtr( $value, UC_CHARS, LC_CHARS )
* )
*);
}
function strtoupper2($value) {
*return (
* strtoupper(
* * strtr( $value, LC_CHARS, UC_CHARS )
* )
*);
}
function ucfirst2($value) {
*return (
* strtoupper2(
* * substr( $value, 0, 1 )
* ).strtolower2(
* * substr( $value, 1, strlen( $value ) )
* )
*);
}
function ucwords2( $value ) {
*$upper = strtoupper2( $value );
*$value = ucfirst2( $value );
*$word_separators = WORD_SEPARATORS;
*$len = strlen( $value ) - 1;
*for ( $i = 0; $i < strlen( $word_separators ); $i++ ) {
* $separator = $word_separators[$i];
* $pos = -1;
* while ( $pos !== false ) {
* * $pos = strpos( $value, $separator, ( $pos + 1 ) );
* * if ( ( $pos !== false ) && ( $pos < $len ) ) {
* * * $value[ ( $pos + 1 ) ] = $upper[ ( $pos + 1 ) ];
* * }
* }
*}
*return ($value);
}
?>
|
Suck! mb_convert_case() exempelvis har funnits i evigheter.
Dags att börja använda kanske. (UCS-4, UCS-4BE, UCS-4LE, UCS-2, UCS-2BE, UCS-2LE, UTF-32, UTF-32BE, UTF-32LE, UTF-16, UTF-16BE, UTF-16LE, UTF-7, UTF7-IMAP, UTF-8, ASCII, EUC-JP, SJIS, eucJP-win, SJIS-win, ISO-2022-JP, JIS, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-13, ISO-8859-14, ISO-8859-15, byte2be, byte2le, byte4be, byte4le, BASE64, HTML-ENTITIES, 7bit, 8bit, EUC-CN, CP936, HZ, EUC-TW, CP950, BIG-5, EUC-KR, UHC (CP949), ISO-2022-KR, Windows-1251 (CP1251), Windows-1252 (CP1252), CP866 (IBM866), KOI8-R stöds om man nu envisas med att inte använda utf-8)