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);
}
?>