Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

strtr function syntax tag tutorial 2013





Alert! Connect with 10,000 Chating Online. Join Now

Php strtr () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 3, PHP 4 , PHP 5)

strtr -- Translate certain characters

Syntax

string strtr ( string str, string from, string to )

string strtr ( string str, array replace_pairs )

This function returns a copy of str, translating all occurrences of each character in from to the corresponding character in to.

If from and to are different lengths, the extra characters in the longer of the two are ignored.

Example 1. strtr() example

<?php
$addr
= strtr($addr, "äåö", "aao");
?>

strtr() may be called with only two arguments. If called with two arguments it behaves in a new way: from then has to be an array that contains string -> string pairs that will be replaced in the source string. strtr() will always look for the longest possible match first and will *NOT* try to replace stuff that it has already worked on.

Example 2. strtr() example with two arguments

<?php
$trans
= array("hello" => "hi", "hi" => "hello");
echo
strtr("hi all, I said hello", $trans);
?>

This will show:

hello all, I said hi

Note: This optional to and from parameters were added in PHP 4.0.0

See also ereg_replace().

Php strtr Function syntax tag

strtr php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php strtr syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online