Join Up!
104886 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousstrtouppersubstr_countnext
Last updated: Tue, 29 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | German

strtr

(PHP 3, PHP 4 )

strtr -- Traduce ciertos caracteres

Descripción

string strtr ( string cad, string desde, string hasta)

Esta función trabaja sobre cad, traduciendo todas las apariciones de cada caracter en desde por el caracter correspondiente en hasta y devolviendo el resultado.

Si desde y hasta son de distinta longitud, los caracteres extra en la más larga son ignorados.

Ejemplo 1. Ejemplo de strtr()

$addr = strtr($addr, "äåö", "aao");

strtr() puede llamarso sólo con dos argumentos. Si se llama de esta manera, se comporta de otro modo: desde debe ser entonces una matriz que contenga pares cadena -> cadena que serán sustituídos en la cadena fuente. strtr() siempre buscará la coincidencia más larga primero y *NO* intentará sustituir nada en lo que haya trabajado ya.

Ejemplos:

$trad = array ("hola" => "hey", "hey" => "hola");
echo strtr("hey a todos, dije hola", $trad) . "\n";

Mostrará: "hola a todos, dije hey",

Nota: Esta característica (2 argumentos) fue añadida en el PHP 4.0

Vea también ereg_replace().

User Contributed Notes
strtr
add a note about notes
There are no user contributed notes for this page.
previousstrtouppersubstr_countnext
Last updated: Tue, 29 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST