String function Library: STRTR

Source: Internet
Author: User
Keywords PHP Chinese function Manual Strtr
Tags aliyun function function library html http php php chinese function manual php3

Strtr

(PHP3, PHP4)

STRTR---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Convert some characters

Syntax: string strtr (String str, string from, string to)

Description:

This function operates on the parameter Str and converts all occurrences of the characters in the argument to the corresponding character in the parameter to, and returns the result.

If the arguments from and to are not the same length, the extra characters for these two arguments are ignored.

Example:

<?php

$ADDR = STRTR ($addr, "麧", "AAO");

?>

Call STRTR () can have only two parameters, and if there are only two parameters, then it will work in a new way: the argument from must be an array containing the string => string pairs, which will be replaced in the original string. STRTR () will look for the first possible alignment and will not attempt to replace the previously processed string.

Example:

<?php

$trans = Array ("Hello" => "Hi", "hi" => "Hello");

echo strtr ("Hi all, I mchumo hello", $trans). "\ n";

?>

This will show: "Hello all, I mchumo hi".

Note: The two-parameter feature is added in PHP 4.0

Reference: Ereg_replace ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.