Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/05/2011, 20:40
Avatar de metacortex
metacortex
Viejo demente
 
Fecha de Ingreso: junio-2004
Ubicación: Caracas - Venezuela
Mensajes: 9.027
Antigüedad: 20 años, 9 meses
Puntos: 832
Respuesta: Dar formato a texto estilo wordpress

Cita:
Iniciado por abimaelrc Ver Mensaje
Puedes usar str_replace y array
Código PHP:
Ver original
  1. $foo = 'á é í ó ú ñ';
  2. $find = array('á', 'é', 'í', 'ó', 'ú', 'ñ', ' ');
  3. $replace = array('a', 'e', 'i', 'o', 'u', 'n', '-');
  4. $foo = str_replace($find, $replace, $foo);
  5. echo $foo; // imprime a-e-i-o-u-n
Mejor:
Código PHP:
Ver original
  1. $texto = 'éste es un examen ñoño';
  2.  
  3. $replace = array(
  4.     ' ' => '-',
  5.     'á' => 'a',
  6.     'é' => 'e',
  7.     'í' => 'i',
  8.     'ó' => 'o',
  9.     'ú' => 'u',
  10.     'ñ' => 'n',
  11.     // etc...
  12. );
  13.  
  14. echo strtr($texto , $replace);
:)