Tema: FAQ's de PHP
Ver Mensaje Individual
  #206 (permalink)  
Antiguo 03/12/2008, 13:45
Avatar de nicolaspar
nicolaspar
 
Fecha de Ingreso: noviembre-2004
Ubicación: Villa Ballester Bs-As|Ar
Mensajes: 2.002
Antigüedad: 19 años, 5 meses
Puntos: 34
Respuesta: FAQ's de PHP

Tema: Strings
Pregunta: Como puedo aplicar un ucfirst a un string si éste comienza con signos?
Respuesta: Mira el siguiente ejemplo:

Código php:
Ver original
  1. <?
  2. /* En tus funciones copia estas dos*/
  3. function uc_first_aux($str){
  4. return ucfirst($str[1]);
  5. }
  6. function uc_first($str){
  7. return preg_replace_callback('/([a-z]){1}/i',"uc_first_aux",$str,1);
  8. }
  9.  
  10. #luego, a un string como este
  11. $str = strtolower('¿¿¡¡COMO ESTÁN USTEDES!!??');
  12.  
  13. #Lo tratas así:
  14. echo uc_first($str); #out: ¿¿¡¡Como están ustedes!!??
  15. ?>
__________________
Mi punto de partida es Que Bueno Lo Nuevo