Ämne: ÅÄÖ i PHP
Visa ett inlägg
Oläst 2007-03-04, 15:08 #2
thorsells avatar
thorsell thorsell är inte uppkopplad
Medlem
 
Reg.datum: Feb 2004
Inlägg: 295
thorsell thorsell är inte uppkopplad
Medlem
thorsells avatar
 
Reg.datum: Feb 2004
Inlägg: 295
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);
}
?>
thorsell är inte uppkopplad   Svara med citatSvara med citat